/* --- 1. BASE & CONTAINERS --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.containerH {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    text-align: center;
}

.pb-80 {
    padding-bottom: 80px;
}

/* --- 2. HEADER --- */
.page-header {
    background: linear-gradient(135deg, rgba(35, 90, 129, 0.1) 0%, rgba(255, 255, 255, 1) 100%);
    padding: 40px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    color: #1f2937;
    font-weight: 800;
    margin: 0;
}

.page-header p {
    color: #666;
    margin-top: 10px;
    font-size: 0.95rem;
}

/* --- 3. TOOLBAR & SEARCH (RESPONSIVE) --- */
.search-bar-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    margin-bottom: 15px;
}

.search-input-group {
    position: relative;
    flex: 1 1 200px;
}

.flex-2 {
    flex: 2 1 300px;
}

.year-group {
    flex: 0 1 120px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.filter-input {
    width: 70%;
    padding: 10px 10px 10px 35px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: 0.2s;
}

.filter-input:focus {
    border-color: #902135;
    outline: none;
    box-shadow: 0 0 0 3px rgba(35, 90, 129, 0.1);
}

/* --- 4. TYPES CAROUSEL --- */
/* --- 4. TYPES CAROUSEL (OPTIMISÉ) --- */
.authors-toolbar {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    gap: 10px;
    margin-bottom: 30px;
    position: relative;
}

/* On cache l'icône sitemap sur très petit écran pour gagner de la place */
.toolbar-header {
    color: #902135;
    font-size: 1.1rem;
    padding-right: 10px;
    border-right: 2px solid #f3f4f6;
    flex-shrink: 0;
}

.carousel-container {
    display: flex;
    align-items: center;
    flex: 1;
    overflow: hidden;
    /* Important pour le défilement */
    position: relative;
}

.alphabet-scroll-container {
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    /* Cache la scrollbar Firefox */
    flex: 1;
    -webkit-overflow-scrolling: touch;
    /* Défilement fluide sur iOS */
}

.alphabet-scroll-container::-webkit-scrollbar {
    display: none;
}

/* Cache la scrollbar Chrome/Safari */

.alpha-item {
    min-width: auto;
    /* On laisse le texte décider de la largeur */
    white-space: nowrap;
    padding: 8px 15px;
    height: auto;
    /* Plus flexible que 38px fixe */
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* .authors-toolbar { 
        display: flex; align-items: center; background: #fff; padding: 10px; 
        border-radius: 12px; border: 1px solid #e5e7eb; gap: 10px; margin-bottom: 30px;
    }*/
/*.toolbar-header { color: #902135; font-size: 1.1rem; padding-right: 10px; border-right: 2px solid #f3f4f6; }*/

/*.carousel-container { display: flex; align-items: center; flex: 1; overflow: hidden; gap: 8px; }*/
/* .alphabet-scroll-container { overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; flex: 1; }
    .alphabet-scroll-container::-webkit-scrollbar { display: none; }*/
.alphabet-track {
    display: flex;
    gap: 12px;
}

/* .alpha-item { 
        min-width: 180px; height: 38px; padding: 0 15px; flex-shrink: 0;
        display: flex; align-items: center; justify-content: center; gap: 8px;
        background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; 
        cursor: pointer; transition: 0.2s; white-space: nowrap;
    }*/
.alpha-item.selected {
    background: #902135;
    border-color: #902135;
    color: #fff;
}

.alpha-item .badge {
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.alpha-item.selected .badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.nav-btn,
.btn-reset {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #902135;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-reset {
    color: #dc2626;
    background: #fee2e2;
    border-color: #fecaca;
}

/* --- 5. RESOURCE CARDS (RESPONSIVE) --- */
.resources-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.resource-main-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 15px;
    transition: 0.3s;
    gap: 15px;
}

.resource-main-card:hover {
    border-color: #902135;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.res-img-thumb {
    width: 50px;
    height: 75px;
    object-fit: cover;
    border-radius: 4px;
}

.res-icon {
    flex-shrink: 0;
    width: 50px;
    height: 75px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.res-content {
    flex: 1;
    min-width: 0;
}

.res-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 5px;
}

.res-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    background: #f3f4f6;
}

.tag-blue {
    background: #e0f2fe;
    color: #902135;
}

.res-title {
    font-size: 1rem;
    margin: 4px 0;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.res-authors {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0;
}

.res-actions {
    margin-left: auto;
}

.btn-view {
    display: inline-block;
    background: #902135;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.res-views {
    font-size: 0.75rem;
    color: #e67e22;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

/* --- 6. PAGINATION --- */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

.pag-btn {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pag-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicators {
    display: flex;
    gap: 5px;
}

.page-num {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    background: #f3f4f6;
    font-size: 0.85rem;
}

.page-num.active {
    background: #902135;
    color: #fff;
}

/* --- 7. MEDIA QUERIES (LE CŒUR DU RESPONSIVE) --- */

/* Tablettes et mobiles larges */
@media (max-width: 768px) {

    .flex-2,
    .flex-1,
    .year-group {
        flex: 1 1 100%;
    }

    /* Tout passe à la ligne */

    .resource-main-card {
        padding: 12px;
        gap: 10px;
    }

    .res-img-thumb,
    .res-icon {
        width: 40px;
        height: 60px;
    }

    .search-bar-container {
        flex-direction: column;
        padding: 15px;
        gap: 10px;

        .authors-toolbar {
            padding: 8px;
            gap: 5px;
        }

        .toolbar-header {
            padding-right: 5px;
            font-size: 1rem;
        }

        .nav-btn {
            display: none;
            /* On cache les flèches sur mobile, le swipe au doigt suffit */
        }

        .alpha-item {
            padding: 6px 12px;
            font-size: 0.8rem;
        }
    }

    /* 2. On centre l'input et on fixe sa largeur */
    .filter-input {
        width: 85% !important;
        /* On augmente un peu pour mobile */
        display: block;
        margin: 0 auto;
        padding-left: 40px;
        /* Un peu plus d'espace pour l'icône */
    }

    /* 3. On repositionne l'icône dynamiquement */
    .search-input-group {
        width: 100%;
        position: relative;
    }

    .search-icon {
        /* Formule : (100% - LargeurInput) / 2 + décalage interne */
        /* Ici : (100% - 85%) / 2 = 7.5% */
        left: calc(6.5% + 0px);
        transform: translateY(-60%);
    }

    .res-title {
        margin: 5px 0;
        font-size: 0.95rem;
        color: #1f2937;
        font-weight: 700;
        line-height: 1.4;
        /* Hauteur de ligne stable pour le calcul du max-height */

        /* 1. Propriété Standard (pour le futur) */
        line-clamp: 2;

        /* 2. Support actuel (Moteurs Blink, Webkit, Gecko) */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;

        /* 3. Comportement visuel */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;

        /* 4. Sécurité (Fallback) si les propriétés ci-dessus échouent */
        max-height: 2.8em;
        /* 2 lignes * 1.4 */
    }

    .btn-text {
        display: none;
    }

    /* On cache le texte Précédent/Suivant sur mobile */
    .pag-btn {
        padding: 8px;
    }
}

/* Petits mobiles */
@media (max-width: 480px) {
    .page-header {
        padding: 25px 0;
    }

    /* .authors-toolbar { flex-wrap: wrap; }*/
    /*.toolbar-header { border: none; padding-bottom: 5px; }*/

    .resource-main-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .res-actions {
        width: 100%;
        margin-top: 10px;
    }

    .btn-view {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    /*.alpha-item { min-width: 140px; }*/

    .toolbar-header {
        display: none;
        /* On gagne un maximum de place */
    }

    .authors-toolbar {
        margin-bottom: 20px;
    }

    /* Optionnel : On peut forcer l'affichage de l'item sélectionné au début */
    .alpha-item.selected {
        border-width: 2px;
    }
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--secondary-gray);
    width: 100%;
    grid-column: 1 / -1;

}

.empty-state-full,
.empty-state-js {
    text-align: center;
    padding: 80px 20px;
    color: var(--secondary-gray);
    width: 100%;
    grid-column: 1 / -1;
}

.empty-state-js {
    display: none;
}

.empty-icon-container {
    margin-bottom: 20px;
}

.empty-icon-large {
    font-size: 3rem;
    color: var(--katalog-bordeaux);
    opacity: 0.8;
}

.empty-title {
    color: var(--text-dark);
}