﻿.collection-nationale {
    margin-top: 80px;
}

.banner {
    background: linear-gradient(307deg, rgba(0, 161, 108, 1) 34%, rgba(19, 100, 79, 1) 89%);
    width: 100%;
    height: 316px;
}

.banner .container div {
    margin-top: -20px;
}

.accordion-notification-badge {
    color: var(--collection-nationale-accent);
    line-height: 0.7;
}

#SearchSection {
    margin-top: -35px;
}

#statutBiologique .accordion-body {
    padding: 1rem 0.3rem;
}

#tblCollectionNationale .accession-name {
    color: var(--color-base-black);
    font-size: 16px;
    font-family: Barlow-Regular;
    font-weight: 700;
    line-height: 24px;
    margin-right: 5px;
    flex: auto;
    text-decoration: none;
}

#tblCollectionNationale .latin-name {
    font-style: italic;
}

#tblCollectionNationale .fw-small {
    font-size: 11px;
}

#tblCollectionNationale .badge-outline-system-success-500 {
    overflow: hidden;
    text-overflow: ellipsis;
}

#treeStatutBiologique a {
    white-space: normal !important;
    height: auto;
    padding: 1px 2px;
}

/* === RESPONSIVE === */

/* Logo responsive - conteneur */
.banner-logo {
    width: 470px;
    height: 190px;
    max-width: 90vw;
}

.banner-logo svg {
    width: 100%;
    height: 100%;
}

/* Sidebar et contenu - marges par défaut */
.sidebar {
    margin-top: 110px;
    margin-left: 60px;
}

.content-section {
    max-width: 1128px;
    margin-left: 60px;
}

/* Écrans moyens (zoom 125% sur 1920px ≈ 1536px effectifs) */
@media (max-width: 1400px) {
    .banner-logo {
        width: 380px;
        height: auto;
    }

    .sidebar {
        margin-left: 30px;
    }

    .content-section {
        margin-left: 30px;
        max-width: calc(100% - 60px);
    }
}

/* Libellés affichés uniquement quand les lignes deviennent des cartes (téléphone).
   Sélecteurs sans l'id du tableau : DataTables mesure les colonnes sur une copie sans id. */
.cn-mobile-label,
.cn-tri-mobile {
    display: none;
}

.cn-badge-groupe-espece {
    width: 95px;
}

/* Bouton qui déplie les filtres latéraux (masqué en bureau par d-lg-none) */
.filtres-cn-bascule {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--bs-gray-300);
    border-radius: 1rem;
    background-color: white;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    font-family: var(--font-family-semibold);
    font-size: 16px;
    color: var(--color-base-black);
}

.filtres-cn-compteur {
    background-color: var(--collection-nationale-accent);
}

.filtres-cn-chevron {
    display: flex;
    transition: transform 0.2s ease-in-out;
}

.filtres-cn-bascule[aria-expanded="true"] .filtres-cn-chevron {
    transform: rotate(180deg);
}

/* Tablettes et téléphones (< 992px) : filtres puis recherche et liste, en pleine largeur */
@media (max-width: 991.98px) {
    /* Après « Appliquer », la liste remonte sous la barre de navigation fixe sans être masquée */
    #tblCollectionNationale_wrapper {
        scroll-margin-top: calc(var(--navbar-height) + 1.5rem);
    }

    .banner {
        height: auto;
        min-height: 200px;
        padding: 2rem 0;
    }

    .banner-logo {
        width: 300px;
        height: auto;
    }

    /* Colonnes empilées (col-12 sous lg) : sans les marges latérales du bureau */
    .collection-nationale .sidebar,
    .collection-nationale .content-section {
        max-width: 100%;
        margin-left: 0;
    }

    .collection-nationale .sidebar {
        margin-top: 30px;
    }

    /* Recherche empilée sous les filtres : sans marge négative (elle chevaucherait le bouton des filtres) */
    #SearchSection {
        margin-top: 0;
    }

    /* Tableau resserré pour tenir dans la largeur d'une tablette */
    #tblCollectionNationale tbody td {
        padding: 0.75rem 0.5rem !important;
    }

    /* Pied du tableau : nombre de lignes, compteur et pagination empilés (col-12 sous lg) */
    #tblCollectionNationale_wrapper .cn-pied-tableau {
        row-gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    #tblCollectionNationale_wrapper .pagination {
        justify-content: center;
        flex-wrap: wrap;
        padding: 0;
    }
}

/* Téléphones (< 768px) : chaque accession devient une carte */
@media (max-width: 767.98px) {
    .banner {
        min-height: 150px;
        padding: 1.5rem 0;
    }

    .banner-logo {
        width: 250px;
    }

    /* Boutons « Contribuer » et « Télécharger » : un par ligne, pleine largeur */
    .cn-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .cn-actions > .preserv-button-primary {
        flex: 1 1 100%;
        text-align: center;
    }

    .cn-telechargements {
        flex: 1 1 100%;
        align-items: center;
    }

    #btnDownloadDonneesCaracterisationFiltered {
        flex: 1 1 auto;
        gap: 0.25rem;
    }

    #btnDownload {
        flex: 0 0 auto;
    }

    /* Sélecteur de tri remplaçant les en-têtes de colonnes */
    .cn-tri-mobile {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .cn-tri-mobile .form-label {
        white-space: nowrap;
    }

    .cn-tri-mobile .form-select {
        width: auto;
        min-width: 0;
    }

    #tblCollectionNationale thead {
        display: none;
    }

    #tblCollectionNationale,
    #tblCollectionNationale tbody {
        display: block;
        width: 100% !important;
    }

    #tblCollectionNationale tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.5rem 0.75rem;
        position: relative;
        min-height: calc(48px + 2rem);
        margin: 1rem 0;
        padding: 1rem 1rem 1rem calc(48px + 1.75rem);
        background-color: var(--color-base-white);
        border-radius: 12px;
        max-height: none;
    }

    #tblCollectionNationale tbody td {
        display: block;
        padding: 0 !important;
        border: 0;
        background-color: transparent;
        box-shadow: none;
        min-width: 0;
        font-size: 12px;
    }

    /* Pictogramme du groupe d'espèces à gauche de la carte */
    #tblCollectionNationale tbody td.cn-col-picto {
        position: absolute;
        top: 1rem;
        left: 1rem;
    }

    /* Nom et numéro d'accession */
    #tblCollectionNationale tbody td.cn-col-nom {
        order: 1;
        flex: 1 1 100%;
    }

    /* Groupe d'espèces puis badge TIRPAA sur la même ligne */
    #tblCollectionNationale tbody td.cn-col-groupe {
        order: 2;
        max-width: 100%;
    }

    #tblCollectionNationale tbody td.cn-col-tirpaa {
        order: 3;
        flex: 0 0 auto;
    }

    #tblCollectionNationale tbody td.cn-col-groupe:empty,
    #tblCollectionNationale tbody td.cn-col-tirpaa:empty {
        display: none;
    }

    #tblCollectionNationale .cn-badge-groupe-espece {
        width: auto;
        max-width: 100%;
    }

    /* Nom commun sur toute la largeur, pays et date côte à côte */
    #tblCollectionNationale tbody td.cn-col-nom-commun {
        order: 4;
        flex: 1 1 100%;
    }

    #tblCollectionNationale tbody td.cn-col-pays,
    #tblCollectionNationale tbody td.cn-col-date {
        order: 5;
        flex: 1 1 calc(50% - 0.75rem);
    }

    #tblCollectionNationale tbody td.cn-col-gestionnaire {
        order: 6;
        flex: 1 1 100%;
    }

    #tblCollectionNationale .cn-mobile-label {
        display: block;
    }

    /* Ligne « aucune accession » : pas de pictogramme */
    #tblCollectionNationale tbody td.dt-empty {
        position: static;
        flex: 1 1 100%;
        text-align: center;
    }

    #tblCollectionNationale tbody tr:has(> td.dt-empty) {
        padding-left: 1rem;
    }
}

/* Petits téléphones : pagination sans les boutons première / dernière page */
@media (max-width: 575.98px) {
    #tblCollectionNationale_wrapper .pagination .page-link.first,
    #tblCollectionNationale_wrapper .pagination .page-link.last {
        display: none;
    }

    #tblCollectionNationale_wrapper .pagination .page-link {
        padding: 0.375rem 0.6rem;
    }
}
