/* Tableaux triables et paginés (public/js/sortable-table.js) */
th.sbd-sortable {
    white-space: nowrap;
}

.sbd-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    white-space: normal;
    cursor: pointer;
}

.sbd-sort-button:hover,
.sbd-sort-button:focus-visible {
    color: var(--bs-primary);
}

/* Deux petites flèches empilées : la flèche du sens actif est colorée */
.sbd-sort-icon {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.sbd-sort-icon::before,
.sbd-sort-icon::after {
    content: '';
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.3;
}

.sbd-sort-icon::before {
    border-bottom: 5px solid currentColor;
}

.sbd-sort-icon::after {
    border-top: 5px solid currentColor;
}

th.sbd-sort-asc .sbd-sort-button,
th.sbd-sort-desc .sbd-sort-button {
    color: var(--bs-primary);
}

th.sbd-sort-asc .sbd-sort-icon::before,
th.sbd-sort-desc .sbd-sort-icon::after {
    opacity: 1;
}

/* Mise en page figée quand le tableau a plusieurs pages : rien ne bouge d'une page à l'autre */
.sbd-table-frame {
    display: flow-root;
}

table.sbd-table-fixed {
    table-layout: fixed;
}

table.sbd-table-fixed td {
    overflow-wrap: anywhere;
}

/* Place de la barre de défilement réservée sur les pages à tableaux, dès le premier affichage :
   la page garde la même largeur avant et après la mise en page figée (classe ajoutée aussi par
   sortable-table.js pour les navigateurs sans :has) */
html:has(table[data-sortable-table]),
html.sbd-scrollbar-gutter {
    scrollbar-gutter: stable;
}

/* Tableau masqué jusqu'à sa mise en forme par sortable-table.js (flèches, colonnes figées) :
   il apparaît d'un coup au lieu de se réajuster sous les yeux. Filet de sécurité : affiché au
   bout de 2 s même si le script n'a pas tourné. */
table[data-sortable-table]:not([data-sortable-table-shown]) {
    visibility: hidden;
    animation: sbd-table-reveal 0s 2s forwards;
}

@keyframes sbd-table-reveal {
    to {
        visibility: visible;
    }
}
