/**
 * PDF Search Lite — Search Styles (harmonisé avec pdf_browser)
 * Même look visuel que l'explorateur de fichiers
 */

/* ========== Container principal ========== */
.psl-search-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.psl-search-page.psl-browser-style {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

/* ========== Toolbar avec recherche ========== */
.psl-search-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
}

.psl-search-toolbar .psl-search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 500px;
}

.psl-search-icon {
    position: absolute;
    left: 18px;
    width: 18px;
    height: 18px;
    color: #9ca3af;
    pointer-events: none;
    z-index: 2;
}

.psl-search-toolbar .psl-search-box .psl-page-search-input {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 44px !important;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    color: #1f2937;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.psl-search-toolbar .psl-search-box .psl-page-search-input::placeholder {
    color: #9ca3af;
}

.psl-search-toolbar .psl-search-box .psl-page-search-input:hover {
    border-color: #9ca3af;
}

.psl-search-toolbar .psl-search-box .psl-page-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.psl-clear-search {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    z-index: 2;
    transition: all 0.15s;
}

.psl-clear-search:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* Compteur de résultats */
.psl-results-count {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

/* ========== Layout principal (sidebar + contenu) ========== */
.psl-search-layout {
    display: flex;
    min-height: 480px;
}

/* Sidebar (même style que browser) */
.psl-search-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.psl-browser-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.psl-browser-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.psl-filters-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.psl-filters-content h4 {
    margin: 20px 0 10px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.psl-filters-content h4:first-child {
    margin-top: 0;
}

/* Items de filtre */
.psl-filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.psl-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    color: #374151;
}

.psl-filter-item:hover {
    background: #e5e7eb;
}

.psl-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.psl-filter-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.psl-filter-count {
    background: #e5e7eb;
    color: #6b7280;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}

.psl-filter-item:hover .psl-filter-count {
    background: #d1d5db;
    color: #374151;
}

/* ========== Zone principale ========== */
.psl-results-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: 480px;
}

/* Barre de tri */
.psl-sort-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}

.psl-sort-btn {
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.psl-sort-btn:hover {
    border-color: #9ca3af;
    color: #374151;
}

.psl-sort-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

/* Liste de résultats */
.psl-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.psl-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Items de fichier */
.psl-result-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    transition: all 0.15s;
}

.psl-result-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.psl-result-pdf {
    border-left: 3px solid #e74c3c;
}

.psl-result-page {
    background: #fafafa;
    border-left: 3px solid #3b82f6;
}

.psl-result-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.psl-result-info {
    flex: 1;
    min-width: 0;
}

.psl-result-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
}

.psl-result-excerpt {
    margin: 0 0 10px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.psl-result-excerpt mark {
    background: #fef3c7;
    color: #92400e;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 500;
}

.psl-result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
}

/* Badges de type (PDF vs Page) */
.psl-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.psl-type-pdf {
    background: #fee2e2;
    color: #dc2626;
}

.psl-type-page {
    background: #dbeafe;
    color: #1d4ed8;
}

.psl-result-category {
    background: #f3f4f6;
    color: #4b5563;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
}

/* Match approximatif */
.psl-result-match-badge {
    display: inline-block;
    margin: 4px 0 8px;
    padding: 3px 10px;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-weight: 600;
}

/* Actions sur les résultats */
.psl-result-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.psl-btn-view,
.psl-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.psl-btn-view {
    background: #eff6ff;
    color: #2563eb;
}

.psl-btn-view:hover {
    background: #2563eb;
    color: #fff;
}

.psl-btn-download {
    background: #f0fdf4;
    color: #16a34a;
}

.psl-btn-download:hover {
    background: #16a34a;
    color: #fff;
}

.psl-btn-view-page {
    background: #eff6ff;
    color: #2563eb;
}

.psl-btn-view-page:hover {
    background: #2563eb;
    color: #fff;
}

.psl-btn-view .dashicons,
.psl-btn-download .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* ========== État vide ========== */
.psl-welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}

.psl-welcome-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: #d1d5db;
}

.psl-welcome-message p {
    margin: 0;
    font-size: 15px;
}

/* ========== Loading ========== */
.psl-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
}

.psl-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: psl-spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes psl-spin {
    to { transform: rotate(360deg); }
}

/* ========== Pagination ========== */
.psl-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.psl-pagination-btn {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.psl-pagination-btn:hover {
    border-color: #9ca3af;
    color: #374151;
}

.psl-pagination-current {
    padding: 8px 14px;
    border-radius: 6px;
    background: #3b82f6;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

.psl-pagination-dots {
    color: #9ca3af;
    padding: 0 4px;
}

/* ========== Suggestions ========== */
.psl-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.psl-suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}

.psl-suggestion-item:hover {
    background: #f9fafb;
}

.psl-suggestion-item:last-child {
    border-bottom: none;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .psl-search-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .psl-search-toolbar .psl-search-box {
        max-width: 100%;
    }
    
    .psl-results-count {
        text-align: center;
    }
    
    .psl-search-layout {
        flex-direction: column;
    }
    
    .psl-search-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .psl-result-item {
        flex-direction: column;
        gap: 12px;
    }
    
    .psl-result-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .psl-btn-view,
    .psl-btn-download {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .psl-search-toolbar {
        padding: 12px 16px;
    }
    
    .psl-search-toolbar .psl-search-box .psl-page-search-input {
        font-size: 16px !important; /* Évite le zoom sur iOS */
    }
    
    .psl-sort-bar {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .psl-sort-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .psl-result-item {
        padding: 12px;
    }
    
    .psl-result-title {
        font-size: 14px;
    }
}
