/* ============================================ */
/* GESTION RESSOURCES DOC - FRONTEND STYLE    */
/* Design moderne avec couleurs de la charte  */
/* ============================================ */

.grd-frontend-wrapper {
    /* Technique pour sortir du conteneur du thème */
    width: 98vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -49vw;
    margin-right: -49vw;
    max-width: none;

    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

/* ============================================ */
/* ONGLETS THÈMES (NAVIGATION HORIZONTALE)    */
/* ============================================ */

.grd-themes-tabs {
    display: flex;
    flex-wrap: wrap;
    /* Permet le retour à la ligne si nécessaire */
    justify-content: center;
    /* Centre les onglets */
    gap: 10px;
    margin-bottom: 30px;
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.grd-theme-tab {
    flex: 1 1 auto;
    /* Flexibilité intelligente */
    min-width: 180px;
    /* Légèrement réduit pour mieux tenir */
    max-width: 300px;
    /* Évite qu'ils soient trop larges */
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 15px;
    /* Légèrement réduit */
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: normal;
    /* Permet le texte sur plusieurs lignes si besoin */
    text-align: center;
    line-height: 1.3;
}

.grd-theme-tab:hover {
    background: #e7f5ff;
    border-color: #009FE3;
    transform: translateY(-2px);
}

.grd-theme-tab.active {
    color: white;
    box-shadow: 0 4px 15px rgba(0, 61, 130, 0.3);
}

/* Couleurs personnalisées par thème */
.grd-theme-tab:nth-child(1).active {
    background: linear-gradient(135deg, #FFC107 0%, #FFD54F 100%);
    border-color: #FFC107;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
}

.grd-theme-tab:nth-child(2).active {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8787 100%);
    border-color: #FF6B6B;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.grd-theme-tab:nth-child(3).active {
    background: linear-gradient(135deg, #A4D65E 0%, #B8E986 100%);
    border-color: #A4D65E;
    box-shadow: 0 4px 15px rgba(164, 214, 94, 0.4);
}

.grd-theme-tab:nth-child(4).active {
    background: linear-gradient(135deg, #003D82 0%, #0056B3 100%);
    border-color: #003D82;
    box-shadow: 0 4px 15px rgba(0, 61, 130, 0.4);
}

.grd-theme-tab:nth-child(5).active {
    background: linear-gradient(135deg, #00A8E8 0%, #00C4FF 100%);
    border-color: #00A8E8;
    box-shadow: 0 4px 15px rgba(0, 168, 232, 0.4);
}

.grd-theme-tab:nth-child(6).active,
.grd-theme-tab:nth-child(n+7).active {
    background: linear-gradient(135deg, #6C757D 0%, #868E96 100%);
    border-color: #6C757D;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

/* ============================================ */
/* ZONE PRINCIPALE                             */
/* ============================================ */

.grd-content-area {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    min-height: 600px;
}

/* ============================================ */
/* SIDEBAR FILTRES                             */
/* ============================================ */

.grd-filters-sidebar {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.grd-search-box {
    margin-bottom: 25px;
}

.grd-search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.grd-search-input:focus {
    outline: none;
    border-color: #009FE3;
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.1);
}

.grd-subthemes-list {
    max-height: 500px;
    overflow-y: auto;
}

.grd-subtheme-group {
    display: none;
}

.grd-subtheme-group.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.grd-subtheme-group h3 {
    font-size: 16px;
    color: #003D82;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.grd-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #495057;
}

.grd-filter-item:hover {
    background: #f0f9ff;
}

.grd-filter-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    /* Assure la taille minimale */
    min-height: 18px;
    /* Assure la taille minimale */
    cursor: pointer;
    flex-shrink: 0;
    /* Empêche le rétrécissement */
    margin-right: 10px;
}

.grd-filter-item input[type="checkbox"]:checked {
    accent-color: #009FE3;
}

.grd-subtheme-category {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.grd-subtheme-category strong {
    display: block;
    margin-bottom: 10px;
    color: #003D82;
    font-size: 14px;
}

.grd-reset-filters {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: #E63946;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.grd-reset-filters:hover {
    background: #c92a2a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

/* ============================================ */
/* ZONE DE DOCUMENTS                           */
/* ============================================ */

.grd-documents-area {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.grd-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.grd-results-header h3 {
    margin: 0;
    font-size: 20px;
    color: #003D82;
}

.grd-results-header span {
    color: #009FE3;
    font-weight: 700;
}

.grd-view-mode {
    display: flex;
    gap: 5px;
}

.grd-view-btn {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.grd-view-btn:hover {
    background: #e7f5ff;
    border-color: #009FE3;
}

.grd-view-btn.active {
    background: #009FE3;
    border-color: #009FE3;
    color: white;
}

.grd-view-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ============================================ */
/* LOADING                                     */
/* ============================================ */

.grd-loading {
    text-align: center;
    padding: 80px 20px;
}

.grd-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #009FE3;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================ */
/* GRILLE DE DOCUMENTS                         */
/* ============================================ */

.grd-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.grd-documents-grid[data-view="list"] {
    grid-template-columns: 1fr;
}

/* Empty state */
.grd-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #adb5bd;
}

.grd-empty-state .dashicons {
    font-size: 80px;
    width: 80px;
    height: 80px;
    opacity: 0.3;
    margin-bottom: 20px;
}

.grd-empty-state h3 {
    color: #6c757d;
    margin: 0 0 10px;
}

.grd-empty-state p {
    color: #adb5bd;
}

/* ============================================ */
/* CARTES DE DOCUMENTS                         */
/* ============================================ */

.grd-doc-card {
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    min-height: 200px;
}

.grd-doc-card:hover {
    border-color: #009FE3;
    box-shadow: 0 8px 20px rgba(0, 159, 227, 0.15);
    transform: translateY(-5px);
}

.grd-doc-card-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 15px;
}

.grd-doc-card-content {
    flex: 1;
}

.grd-doc-card h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;

    /* Limiter à 2 lignes */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
    /* Standard property for compatibility */
}

.grd-doc-card-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 15px;
}

.grd-doc-card-meta span {
    padding: 4px 10px;
    background: white;
    border-radius: 12px;
    font-weight: 600;
}

.grd-doc-card-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    background: #009FE3;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.grd-doc-card-btn:hover {
    background: #003D82;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 61, 130, 0.3);
}

.grd-doc-card-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ============================================ */
/* MODE LISTE                                  */
/* ============================================ */

.grd-documents-grid[data-view="list"] .grd-doc-card {
    flex-direction: row;
    align-items: stretch;
    /* Hauteur pleine */
    gap: 0;
    /* Géré par padding interne */
    min-height: auto;
    padding: 0;
    /* Retirer padding global */
    overflow: hidden;
    /* Pour que l'image respecte les bords arrondis */
}

/* Conteneur de l'image ou icône (gauche) */
.grd-documents-grid[data-view="list"] .grd-doc-card-icon {
    margin: 0;
    font-size: 40px;
    width: 80px;
    /* Largeur réduite pour correspondre à la hauteur attendue */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    /* Fond léger */
    border-right: 1px solid #e9ecef;
}

/* L'image elle-même */
.grd-documents-grid[data-view="list"] .grd-doc-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Affiche l'image entière sans couper */
    display: block;
}

/* Le contenu texte (milieu) */
.grd-documents-grid[data-view="list"] .grd-doc-card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Le titre */
.grd-documents-grid[data-view="list"] .grd-doc-card h4 {
    min-height: auto;
    margin-top: 0;
}

/* Le bouton (droite) */
.grd-documents-grid[data-view="list"] .grd-doc-card-btn {
    flex-shrink: 0;
    width: auto;
    margin: 20px;
    /* Marge autour du bouton */
    align-self: center;
}

/* ============================================ */
/* RESPONSIVE                                  */
/* ============================================ */

@media (max-width: 1200px) {
    .grd-content-area {
        grid-template-columns: 1fr;
    }

    .grd-filters-sidebar {
        position: static;
    }

    .grd-themes-tabs {
        flex-wrap: wrap;
    }

    .grd-theme-tab {
        min-width: calc(50% - 5px);
    }
}

@media (max-width: 768px) {
    .grd-frontend-wrapper {
        padding: 0 15px;
    }

    .grd-themes-tabs {
        flex-direction: column;
    }

    .grd-theme-tab {
        min-width: 100%;
    }

    .grd-documents-grid {
        grid-template-columns: 1fr;
    }

    .grd-results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .grd-documents-area {
        padding: 20px 15px;
    }

    .grd-filters-sidebar {
        padding: 20px 15px;
    }
}

/* ============================================ */
/* SCROLLBAR PERSONNALISÉE                     */
/* ============================================ */

.grd-subthemes-list::-webkit-scrollbar {
    width: 8px;
}

.grd-subthemes-list::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 4px;
}

.grd-subthemes-list::-webkit-scrollbar-thumb {
    background: #009FE3;
    border-radius: 4px;
}

.grd-subthemes-list::-webkit-scrollbar-thumb:hover {
    background: #003D82;
}

/* ============================================ */
/* AJUSTEMENTS MOBILE (SMARTPHONE)             */
/* ============================================ */

@media (max-width: 768px) {
    /* Masquer les métadonnées (taille, éditeur, type) sur mobile */
    .grd-documents-grid[data-view="list"] .grd-doc-card-meta {
        display: none !important;
    }

    /* Layout Grille pour la carte sur mobile pour placer le bouton sous le titre */
    .grd-documents-grid[data-view="list"] .grd-doc-card {
        display: grid;
        grid-template-columns: 70px 1fr;
        grid-template-rows: auto auto;
        align-items: start;
        padding: 0;
        height: auto;
        min-height: auto;
    }

    /* Ajustement de l'icône */
    .grd-documents-grid[data-view="list"] .grd-doc-card-icon {
        grid-row: 1 / -1; /* Prend toute la hauteur */
        width: 100%;
        height: auto;
        min-height: 90px;
        font-size: 30px;
    }

    /* Ajustement du contenu (Titre) */
    .grd-documents-grid[data-view="list"] .grd-doc-card-content {
        grid-column: 2;
        padding: 15px 15px 5px 15px;
        display: block;
    }

    .grd-documents-grid[data-view="list"] .grd-doc-card h4 {
        margin-bottom: 5px;
        font-size: 15px;
        /* Max 3 lignes sur mobile */
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    /* Positionnement du bouton "Télécharger" à la place des métadonnées */
    .grd-documents-grid[data-view="list"] .grd-doc-card-btn {
        grid-column: 2;
        margin: 0 15px 15px 15px;
        width: fit-content;
        justify-self: start;
        padding: 8px 12px;
        font-size: 13px;
    }
}