/* ------------------------------------------------------------------------------------
   dirDataTable — habillage de la liste de données

   Ce fichier est chargé APRÈS 03_hack.css, qui impose à toute l'application :

       table    { table-layout: fixed; }
       table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

   La première règle nous arrange : sans elle, le navigateur redistribue les largeurs
   comme il l'entend et les poignées de redimensionnement ne servent à rien.
   La seconde est justement ce qui coupe le contenu ; on la lève colonne par colonne,
   sur demande, via l'option `wrap`.
   ------------------------------------------------------------------------------------ */

.gf-dt {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Le retour en haut de liste au changement de page passe par scrollIntoView.
       Sans cette marge, l'en-tête fixe de l'application recouvrirait la première
       ligne. La valeur suit la hauteur de cet en-tête. */
    scroll-margin-top: 110px;
}

@media (max-width: 991.98px) {
    .gf-dt {
        scroll-margin-top: 60px;
    }
}

/* --- Barre d'outils ---------------------------------------------------------------- */

.gf-dt-barre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    min-height: 31px;
}

.gf-dt-barre-gauche,
.gf-dt-barre-droite {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gf-dt-compteur {
    font-size: 0.8125rem;
    color: #6c757d;
    white-space: nowrap;
}

.gf-dt-taille {
    width: auto;
    min-width: 72px;
}

/* --- Menu de choix des colonnes ---------------------------------------------------- */

.gf-dt-menu-conteneur {
    position: relative;
}

.gf-dt-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1030;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px 0;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gf-dt-menu-ligne {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 4px 12px;
    font-weight: normal;
    cursor: pointer;
    white-space: nowrap;
}

.gf-dt-menu-ligne:hover {
    background-color: rgba(0,0,0,0.05);
}

.gf-dt-menu-ligne-figee {
    opacity: 0.55;
    cursor: default;
}

.gf-dt-menu-pied {
    border-top: 1px solid rgba(0,0,0,0.1);
    margin-top: 4px;
    padding-top: 4px;
    text-align: center;
}

/* --- Tableau ----------------------------------------------------------------------- */

.gf-dt-cadre {
    overflow-x: auto;
    overflow-y: auto;
    min-width: 0;
}

.gf-dt-table {
    margin-bottom: 0;
}

.gf-dt-th {
    position: relative;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    /* La poignée occupe les 8 derniers pixels : on réserve la place pour que le
       libellé ne passe pas dessous. */
    padding-right: 14px !important;
}

.gf-dt-th-libelle {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.gf-dt-triable .gf-dt-th-libelle {
    cursor: pointer;
}

.gf-dt-triable:hover .gf-dt-th-libelle {
    text-decoration: underline;
}

.gf-dt-fleche {
    margin-left: 3px;
    font-size: 0.75em;
    color: #495057;
}

/* En-tête collant : n'a d'effet que si le cadre défile, donc que si l'appelant a
   fixé une hauteur maximale. Inoffensif sinon. */
.gf-dt-sticky .gf-dt-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #fff;
    /* Une bordure ordinaire disparaît en défilant : le box-shadow, lui, tient. */
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* --- Poignée de redimensionnement --------------------------------------------------- */

.gf-dt-poignee {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    /* Repère discret, franc au survol : la zone saisissable doit se deviner. */
    background: linear-gradient(to right, transparent 0, transparent 3px, rgba(0,0,0,0.12) 3px, rgba(0,0,0,0.12) 4px, transparent 4px);
}

.gf-dt-poignee:hover {
    background: linear-gradient(to right, transparent 0, transparent 3px, #007bff 3px, #007bff 5px, transparent 5px);
}

/* Pendant le glissement, on neutralise la sélection de texte sur toute la page :
   sinon le navigateur surligne les en-têtes au passage du curseur. */
body.gf-dt-redim-en-cours {
    cursor: col-resize !important;
    user-select: none !important;
}

body.gf-dt-redim-en-cours * {
    cursor: col-resize !important;
}

/* --- Cellules ----------------------------------------------------------------------- */

.gf-dt-table td {
    vertical-align: middle;
}

.gf-dt-align-left { text-align: left; }
.gf-dt-align-center { text-align: center; }
.gf-dt-align-right { text-align: right; }

/* Lève le nowrap global de 03_hack.css pour les colonnes déclarées `wrap: true`. */
.gf-dt-table td.gf-dt-wrap {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
}

.gf-dt-selecteur {
    width: 36px;
    text-align: center;
    vertical-align: middle;
}

.gf-dt-actions {
    display: inline-flex;
    gap: 2px;
    white-space: nowrap;
}

.gf-dt-table tbody tr {
    cursor: pointer;
}

.gf-dt-table tbody tr.gf-dt-courante > td {
    background-color: rgba(0,123,255,0.10);
}

.gf-dt-table tbody tr.gf-dt-selectionnee > td {
    background-color: rgba(40,167,69,0.10);
}

.gf-dt-table tbody tr:focus {
    outline: 2px solid rgba(0,123,255,0.45);
    outline-offset: -2px;
}

/* --- Densité compacte ---------------------------------------------------------------- */

.gf-dt-compact .gf-dt-table th,
.gf-dt-compact .gf-dt-table td {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    font-size: 0.8125rem;
}

/* --- États --------------------------------------------------------------------------- */

.gf-dt-etat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 12px;
    color: #6c757d;
    font-size: 0.875rem;
}

.gf-dt-vide {
    flex-direction: column;
    gap: 6px;
    padding: 32px 12px;
}

.gf-dt-vide .fa-folder-open,
.gf-dt-vide .far {
    font-size: 1.6rem;
    opacity: 0.45;
}

.gf-dt-erreur {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

/* --- Pied de liste -------------------------------------------------------------------- */

.gf-dt-pied {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.gf-dt-pied .pagination {
    margin-bottom: 0;
}

.gf-dt-pied .page-link {
    border: 0;
    background: transparent;
}

/* --- Affichage en cartes (téléphone) --------------------------------------------------- */

.gf-dt-cartes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gf-dt-carte {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
}

.gf-dt-carte.gf-dt-courante {
    border-color: #007bff;
    box-shadow: 0 0 0 1px #007bff inset;
}

.gf-dt-carte.gf-dt-selectionnee {
    background-color: rgba(40,167,69,0.07);
}

.gf-dt-carte:focus {
    outline: 2px solid rgba(0,123,255,0.45);
    outline-offset: 1px;
}

.gf-dt-carte-ligne {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px dashed rgba(0,0,0,0.06);
}

.gf-dt-carte-ligne:last-child {
    border-bottom: 0;
}

.gf-dt-carte-etiquette {
    flex: 0 0 auto;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #6c757d;
}

.gf-dt-carte-valeur {
    flex: 1 1 auto;
    text-align: right;
    /* En carte on laisse le texte revenir à la ligne : c'est tout l'intérêt du mode,
       et la place en largeur manque de toute façon. */
    white-space: normal;
    word-break: break-word;
}

.gf-dt-carte-selecteur {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #6c757d;
    font-weight: normal;
}

/* Une ligne d'actions n'a pas d'étiquette : les boutons occupent toute la largeur
   et se rangent à droite, comme dans le tableau. */
.gf-dt-carte-ligne-actions {
    justify-content: flex-end;
    border-bottom: 0;
    padding-top: 6px;
}

/* Sur petit écran, la barre d'outils passe en colonne plutôt que de déborder. */
@media (max-width: 767.98px) {
    .gf-dt-barre {
        flex-wrap: wrap;
        gap: 6px;
    }

    .gf-dt-libelle-bouton {
        display: none;
    }

    .gf-dt-pied {
        justify-content: center;
    }
}
