/*
 * Tableaux de liste : mise en page sobre, inspirée des tableaux de bord (carte à bordure fine,
 * défilement horizontal à l'intérieur de la carte, en-tête gris, séparateurs de colonnes, lignes fines,
 * survol discret, chiffres alignés, colonne d'actions fixée à droite, roue pour afficher ou masquer les colonnes).
 * S'applique aux tableaux placés directement dans un conteneur « overflow-x-auto ».
 * Équivalent CSS de « isolate grid relative min-w-full overflow-y-clip w-max » (non compilé dans app.css).
 * Les classes Tailwind de largeur, de taille et d'alignement des cellules restent prioritaires.
 */

.overflow-x-auto:has(> table) {
  display: grid;
  position: relative;
  isolation: isolate;
  min-width: 100%;
  overflow-x: auto;
  overflow-y: clip;
  background: #fff;
  border: 1px solid rgb(210 210 215);
  border-radius: 12px;
}

/* Largeur selon le contenu, au minimum la largeur du conteneur. Spécificité nulle : une classe w-full ou min-w-[…] l'emporte. */
:where(.overflow-x-auto:has(> table) > table) {
  width: max-content;
  min-width: 100%;
}

.overflow-x-auto > table {
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.overflow-x-auto > table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafb;
  color: rgb(110 110 115);
  font-size: 12.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgb(210 210 215);
}

.overflow-x-auto > table > thead > tr > th + th {
  border-left: 1px solid rgb(232 232 237);
}

.overflow-x-auto > table > tbody > tr > td {
  padding-top: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgb(232 232 237);
  color: rgb(29 29 31);
  vertical-align: middle;
}

.overflow-x-auto > table > tbody > tr:last-child > td {
  border-bottom: 0;
}

.overflow-x-auto > table > tbody > tr:hover > td {
  background: #fafafb;
}

/* Ligne de total ou de pied : même gris que l'en-tête, sans survol */
.overflow-x-auto > table > tfoot > tr > td,
.overflow-x-auto > table > tfoot > tr > th {
  background: #fafafb;
  font-weight: 600;
  border-top: 1px solid rgb(210 210 215);
}

/* Colonne d'actions (tableaux à menu « ··· ») : fixée à droite pendant le défilement horizontal */
.overflow-x-auto > table[data-actions] > thead > tr > th:last-child {
  top: 0;
  right: 0;
  z-index: 3;
  background: #fafafb;
  box-shadow: -8px 0 8px -8px rgb(0 0 0 / 12%);
  text-align: right;
}

.overflow-x-auto > table[data-actions] > tbody > tr > td:last-child,
.overflow-x-auto > table[data-actions] > tfoot > tr > td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -8px 0 8px -8px rgb(0 0 0 / 12%);
  text-align: right;
}

.overflow-x-auto > table[data-actions] > tbody > tr:hover > td:last-child {
  background: #fafafb;
}

/* Largeur de la colonne d'actions : juste ce qu'il faut pour la roue ou le bouton « ··· » */
.overflow-x-auto > table[data-actions] > thead > tr > th:last-child,
.overflow-x-auto > table[data-actions] > tbody > tr > td:last-child,
.overflow-x-auto > table[data-actions] > tfoot > tr > td:last-child {
  width: 1%;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 12px;
}

/* Boutons ronds : roue de l'en-tête et menu « ··· » des lignes */
.tbl-bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: rgb(110 110 115);
  cursor: pointer;
}

.tbl-bouton:hover {
  background: #f5f5f7;
  color: rgb(29 29 31);
}

.tbl-bouton:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(0 113 227 / 35%);
}

/* Liste des colonnes affichées (ouverte par la roue) */
.tbl-colonnes {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px 0;
  background: #fff;
  border: 1px solid rgb(210 210 215);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 18%);
  font-size: 14px;
  color: rgb(29 29 31);
}

.tbl-titre {
  padding: 6px 14px 8px;
  font-size: 12px;
  font-weight: 600;
  color: rgb(110 110 115);
}

/* « Exporter Excel » dans la liste de la roue, et séparateur avant « Colonnes affichées » */
.tbl-action {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
  color: rgb(29 29 31);
  cursor: pointer;
}

.tbl-action:hover {
  background: #f5f5f7;
}

.tbl-sep {
  height: 1px;
  margin: 6px 0;
  background: rgb(232 232 237);
}

/* Le bouton « Exporter Excel » de la barre d'outils est remplacé par celui de la roue dès qu'un tableau a une roue */
body:has(table[data-actions]) #etatExport {
  display: none;
}

.tbl-colonnes label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
}

.tbl-colonnes label:hover {
  background: #f5f5f7;
}

.tbl-colonnes input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: rgb(0 113 227);
}

.tbl-raz {
  display: block;
  margin: 6px 14px 2px;
  padding: 0;
  border: 0;
  background: none;
  color: rgb(0 113 227);
  font-size: 13px;
  cursor: pointer;
}
