/**
 * PDF Search Lite — Search Styles avec checkboxes alignées et sélection multiple
 */

/* ========== 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;
}

/* ========== Top Bar (recherche + filtres actifs) ========== */
.psl-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.psl-top-bar .psl-search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.psl-search-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: #9ca3af;
    pointer-events: none;
    z-index: 2;
}

.psl-top-bar .psl-search-box .psl-page-search-input {
    width: 100%;
    height: 38px;
    padding: 0 36px 0 40px !important;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    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-top-bar .psl-search-box .psl-page-search-input::placeholder {
    color: #9ca3af;
}

.psl-top-bar .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: 10px;
    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;
}

/* Filtres actifs (tags) */
.psl-active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.psl-filters-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.psl-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.psl-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: #dbeafe;
    color: #1d4ed8;
}

.psl-filter-tag.psl-year-tag {
    background: #d1fae5;
    color: #047857;
}

.psl-filter-tag .psl-tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
}

.psl-filter-tag .psl-tag-remove:hover {
    background: rgba(255,255,255,0.9);
}

.psl-reset-filters {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.15s;
}

.psl-reset-filters:hover {
    color: #374151;
}

/* Bouton Tout effacer en haut */
.psl-reset-filters-top {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.psl-reset-filters-top:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

/* Compteur de résultats */
.psl-results-count {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}

/* ========== Layout principal ========== */
.psl-search-layout {
    display: flex;
    min-height: 560px;
    max-height: 82vh;
}

/* Sidebar */
.psl-search-sidebar {
    width: 272px;
    background: #f8f9fa;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== Bouton "Tous les PDFs" ========== */
.psl-all-pdfs-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 9px;
    margin: 3px 4px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.psl-all-pdfs-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.psl-all-pdfs-btn.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.psl-all-pdfs-btn input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #2271b1;
}

.psl-all-pdfs-btn svg {
    color: #666;
    flex-shrink: 0;
}

.psl-all-pdfs-btn.active svg {
    color: #fff;
}

.psl-all-count {
    margin-left: auto;
    background: #e5e7eb;
    color: #6b7280;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 500;
}

.psl-all-pdfs-btn.active .psl-all-count {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Header de section */
.psl-browser-header {
    padding: 4px 8px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.psl-browser-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== Folder Tree ========== */
.psl-folder-tree {
    flex: 1;
    overflow-y: auto;
    padding: 2px 0;
    min-height: 100px;
}

.psl-folder-item {
    position: relative;
}

/* Row contenant tous les éléments alignés */
.psl-folder-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    padding: 0 2px;
    margin: 0 2px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    line-height: 1.15;
}

.psl-folder-row:hover {
    background: #e9ecef;
}

.psl-folder-item.selected .psl-folder-row {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Toggle pour déplier/replier */
.psl-folder-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    color: #6b7280;
}

.psl-folder-toggle:hover {
    background: rgba(0,0,0,0.1);
}

.psl-folder-toggle svg {
    transition: transform 0.2s;
    display: block;
}

.psl-folder-item.expanded > .psl-folder-children {
    display: block !important;
}

.psl-folder-item.expanded > .psl-folder-row .psl-folder-toggle svg {
    transform: rotate(90deg);
}

.psl-folder-toggle-placeholder {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* Checkbox pour sélectionner */
.psl-folder-checkbox {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    accent-color: #2271b1;
}

/* Header du dossier (icone + nom + badge) */
.psl-folder-header {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.psl-folder-icon {
    flex-shrink: 0;
    color: #f4d03f;
}

.psl-folder-item.selected .psl-folder-icon {
    color: #1d4ed8;
}

.psl-folder-name {
    flex: 1;
    font-size: 12px;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.psl-folder-badge {
    background: #e5e7eb;
    color: #6b7280;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 10px;
    line-height: 16px;
    font-weight: 500;
    flex-shrink: 0;
}

.psl-folder-item.selected .psl-folder-badge {
    background: #bfdbfe;
    color: #1d4ed8;
}

/* Enfants */
.psl-folder-children {
    position: relative;
    margin-left: 1px;
    padding-left: 3px;
    border-left: 1px solid #e5e7eb;
}

.psl-loading-folders {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
    gap: 10px;
}

.psl-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #eee;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: psl-spin 1s linear infinite;
    display: inline-block;
}

@keyframes psl-spin {
    to { transform: rotate(360deg); }
}

/* ========== Section Filtres (Années) ========== */
.psl-filters-section {
    border-top: 1px solid #e2e8f0;
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

.psl-year-filters {
    overflow-y: auto;
    padding: 8px;
    max-height: 200px;
}

.psl-filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.psl-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    color: #374151;
}

.psl-filter-item:hover {
    background: #e5e7eb;
}

.psl-filter-item.active {
    background: #d1fae5;
    color: #047857;
}

.psl-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #059669;
}

.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,
.psl-filter-item.active .psl-filter-count {
    background: #a7f3d0;
    color: #047857;
}

/* ========== Zone principale ========== */
.psl-results-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: 560px;
    overflow: hidden;
}

/* Toolbar avec breadcrumb */
.psl-browser-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.psl-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-wrap: wrap;
}

.psl-breadcrumb-root {
    color: #2271b1;
    cursor: pointer;
    font-weight: 500;
}

.psl-breadcrumb-root:hover {
    text-decoration: underline;
}

.psl-breadcrumb-separator {
    color: #9ca3af;
}

.psl-breadcrumb-part {
    color: #374151;
    cursor: pointer;
}

.psl-breadcrumb-part:hover {
    color: #2271b1;
    text-decoration: underline;
}

.psl-file-count {
    font-size: 13px;
    color: #6b7280;
    flex-shrink: 0;
}

/* Barre de tri */
.psl-sort-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
    flex-shrink: 0;
}

.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: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

/* Sélecteur par page */
.psl-per-page {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    flex-shrink: 0;
}

.psl-per-page-select {
    height: 28px;
    padding: 0 6px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #fff;
    color: #374151;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.psl-per-page-select:focus {
    border-color: #3b82f6;
}

/* Liste de résultats */
.psl-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    max-height: calc(82vh - 168px);
}

.psl-results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Items de fichier */
.psl-result-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    transition: all 0.15s;
    margin-bottom: 3px;
}

.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;
    border-radius: 10px;
}

.psl-result-info {
    flex: 1;
    min-width: 0;
}

.psl-result-title {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
}

.psl-result-excerpt {
    margin: 0 0 4px;
    font-size: 13px;
    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;
}

.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 */
.psl-result-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.psl-btn-view,
.psl-btn-view:visited,
.psl-btn-download,
.psl-btn-download:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid #d9e2ec;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
}

.psl-btn-view {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.psl-result-actions .psl-btn-view:hover,
.psl-result-actions .psl-btn-view:focus,
.psl-result-actions .psl-btn-view:active {
    border-color: #1d4ed8 !important;
    background: #1d4ed8 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(29, 78, 216, 0.18);
}

.psl-btn-download {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

.psl-result-actions .psl-btn-download:hover,
.psl-result-actions .psl-btn-download:focus,
.psl-result-actions .psl-btn-download:active {
    border-color: #15803d !important;
    background: #15803d !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(21, 128, 61, 0.18);
}

.psl-btn-view-page {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.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: 28px 18px;
    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;
}

.psl-error {
    color: #dc2626;
    padding: 16px;
    text-align: center;
}

.psl-empty {
    color: #9ca3af;
    padding: 16px;
    text-align: center;
    font-size: 13px;
}

/* ========== Loading ========== */
.psl-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 18px;
    color: #6b7280;
}

.psl-loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e5e7eb;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: psl-spin 1s linear infinite;
    margin-bottom: 16px;
}

/* ========== Pagination ========== */
.psl-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    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: #2271b1;
    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-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .psl-top-bar .psl-search-box {
        max-width: 100%;
    }
    
    .psl-active-filters {
        order: 3;
    }
    
    .psl-results-count {
        text-align: center;
    }
    
    .psl-search-layout {
        flex-direction: column;
        max-height: none;
    }

    .psl-search-sidebar {
        width: 100%;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .psl-folder-tree {
        min-height: 220px;
        max-height: 45vh;
    }

    .psl-results-main {
        min-height: 400px;
    }

    .psl-filters-section {
        max-height: 150px;
    }

    .psl-year-filters {
        max-height: 100px;
    }
    
    .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-top-bar {
        padding: 12px 16px;
    }
    
    .psl-top-bar .psl-search-box .psl-page-search-input {
        font-size: 16px !important;
    }
    
    .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;
    }
}
