/**
 * Frontend File Explorer - Search Addon Styles
 */

/* Correção de bug do plugin base (frontend-file-explorer <= 1.0.10):
   .frontend-file-explorer-items usa grid-template-columns com minmax(180px, 1fr),
   o que deixa as colunas elásticas e gera vãos enormes/irregulares entre as pastas
   em containers largos. Aqui travamos a largura da coluna e alinhamos à esquerda.
   Seletor composto (2 classes) para vencer a especificidade do CSS original
   independente da ordem de carregamento dos dois plugins. Remover esta regra (e as
   duas media queries abaixo) se o autor original corrigir isso em uma atualização. */
.frontend-file-explorer-frontend-container .frontend-file-explorer-items {
    grid-template-columns: repeat(auto-fill, minmax(180px, 200px));
    justify-content: start;
}

@media (max-width: 782px) {
    .frontend-file-explorer-frontend-container .frontend-file-explorer-items {
        grid-template-columns: repeat(auto-fill, minmax(140px, 160px));
    }
}

@media (max-width: 480px) {
    .frontend-file-explorer-frontend-container .frontend-file-explorer-items {
        grid-template-columns: repeat(auto-fill, minmax(120px, 140px));
    }
}

/* Search bar */
.ffes-search-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 15px;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.ffes-search-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.ffes-search-icon {
    color: #888;
    font-size: 20px;
    flex-shrink: 0;
}

.ffes-search-input {
    flex: 1 1 auto;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.ffes-search-input:focus {
    border-color: #0073aa;
}

.ffes-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    display: flex;
    align-items: center;
    padding: 4px;
    flex-shrink: 0;
}

.ffes-search-clear:hover {
    color: #333;
}

/* Optional file-type filter — secondary row, kept small and out of the way */
.ffes-search-row-type {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 28px;
}

.ffes-search-type-label {
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
}

.ffes-search-type {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 12px;
    color: #555;
    background-color: #fff;
    max-width: 160px;
}

.ffes-search-credit {
    margin: 0;
    padding: 6px 15px 12px;
    text-align: right;
    font-size: 11px;
    color: #a3a3a3;
}

.ffes-search-credit a {
    color: inherit;
    text-decoration: none;
}

.ffes-search-credit a:hover {
    text-decoration: underline;
}

/* Status line (searching / no results / min chars / truncated) */
.ffes-search-status {
    display: none;
    padding: 0 0 15px;
    font-size: 13px;
    color: #777;
}

.ffes-searching .ffes-search-status {
    display: block;
}

/* Results grid — reuses .frontend-file-explorer-items grid layout.
   Selectors below use two classes (instead of relying on stylesheet
   load order) so they reliably beat .frontend-file-explorer-items{display:grid}
   from the base plugin's own stylesheet regardless of enqueue order. */
.ffes-search-results.frontend-file-explorer-items {
    display: none;
}

.ffes-searching .ffes-search-results.frontend-file-explorer-items {
    display: grid;
}

/* Hide the normal browsing UI while a search is active */
.ffes-searching #frontend-file-explorer-frontend-items,
.ffes-searching #frontend-file-explorer-frontend-empty,
.ffes-searching #frontend-file-explorer-frontend-loading,
.ffes-searching .frontend-file-explorer-pagination {
    display: none !important;
}

/* Slightly taller cards to fit the extra location line */
.frontend-file-explorer-item.ffes-search-result-item {
    height: 240px;
}

.ffes-search-item-path {
    font-size: 11px;
    color: #999;
    margin-top: -6px;
    margin-bottom: 10px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
