/*
 * IMMGO — Charte : grille du tableau de bord, tableau dense, graphique à barres et jauge
 * Auteur : Jacks Ngalangala
 */

/* ─── Grille du tableau de bord : graphique à gauche, liste à droite ; une colonne sous 1024 px ─── */
.grille-tableau-de-bord {
  display: grid;
  gap: var(--e-6);
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  align-items: start;
}
@media (max-width: 1023px) {
  .grille-tableau-de-bord {
    grid-template-columns: 1fr;
  }
}

/* ─── Tableau dense ─── */
.tableau-cadre {
  overflow-x: auto;
  border: 1px solid var(--trait);
  border-radius: var(--r-grand);
  background: var(--surface);
}
.tableau {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--taille-petit);
}
.tableau th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 44px;
  padding: 0 var(--e-4);
  background: var(--surface-douce);
  border-bottom: 1px solid var(--trait);
  color: var(--texte-second);
  font-size: var(--taille-legende);
  font-weight: var(--graisse-forte);
  text-align: left;
  white-space: nowrap;
}
.tableau th:first-child,
.tableau td:first-child {
  padding-left: var(--e-6);
}
.tableau th:last-child,
.tableau td:last-child {
  padding-right: var(--e-4);
}
.tableau-tri {
  display: inline-flex;
  align-items: center;
  gap: var(--e-1);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}
.tableau-tri svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}
.tableau th[aria-sort] .tableau-tri svg {
  opacity: 1;
  color: var(--or-texte);
}
.tableau th[aria-sort='descending'] .tableau-tri svg {
  transform: rotate(180deg);
}
.tableau td {
  height: 56px;
  padding: 0 var(--e-4);
  border-bottom: 1px solid var(--trait);
  vertical-align: middle;
}
.tableau tr:last-child td {
  border-bottom: 0;
}
.tableau tbody tr[data-cliquable] {
  cursor: pointer;
}
.tableau tbody tr:hover td {
  background: var(--surface-douce);
}
.tableau .a-droite {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tableau .colonne-menu {
  width: 56px;
  text-align: right;
}
.tableau-principal {
  font-weight: var(--graisse-forte);
  color: var(--texte);
}
.tableau-secondaire {
  display: block;
  font-size: var(--taille-legende);
  color: var(--texte-faible);
}

/* Sous 600 px : chaque ligne devient une petite carte, libellé de colonne au-dessus de la valeur */
@media (max-width: 599px) {
  .tableau thead {
    display: none;
  }
  .tableau,
  .tableau tbody,
  .tableau tr,
  .tableau td {
    display: block;
    width: 100%;
  }
  .tableau tr {
    padding: var(--e-3) var(--e-4);
    border-bottom: 1px solid var(--trait);
  }
  .tableau td {
    height: auto;
    padding: var(--e-1) 0 !important;
    border: 0;
    text-align: left !important;
  }
  .tableau td[data-libelle]::before {
    content: attr(data-libelle);
    display: block;
    font-size: var(--taille-legende);
    color: var(--texte-faible);
  }
}

/* ─── Graphique à barres (une série, une couleur, valeur au survol) ─── */
.graphique {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
}
.graphique-zone {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: var(--e-4);
  height: 232px;
  padding: var(--e-8) var(--e-2) 0; /* place pour la bulle de la plus haute barre */
  border-bottom: 1px solid var(--trait-fort);
  background-image: linear-gradient(var(--trait) 1px, transparent 1px);
  background-size: 100% 25%;
}
.graphique-colonne {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
}
.graphique-barre {
  width: min(40px, 70%);
  height: calc(var(--hauteur, 0) * 1%);
  border-radius: 4px 4px 0 0;
  background: var(--or);
  transition: height 400ms var(--courbe);
}
.graphique-colonne:hover .graphique-barre,
.graphique-colonne:focus-visible .graphique-barre {
  background: var(--or-fonce);
}
.graphique-bulle {
  position: absolute;
  bottom: calc(var(--hauteur, 0) * 1% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--e-1) var(--e-2);
  border-radius: var(--r-petit);
  background: var(--nuit);
  color: var(--nuit-texte);
  font-size: var(--taille-legende);
  font-weight: var(--graisse-forte);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duree) var(--courbe);
}
.graphique-colonne:hover .graphique-bulle,
.graphique-colonne:focus-visible .graphique-bulle,
.graphique-colonne[data-dernier] .graphique-bulle {
  opacity: 1;
}
.graphique-axe {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--e-4);
  padding: 0 var(--e-2);
  font-size: var(--taille-legende);
  color: var(--texte-faible);
  text-align: center;
}

/* ─── Jauge (taux d'occupation, avancement) ─── */
.jauge {
  height: 8px;
  border-radius: var(--r-pilule);
  background: var(--neutre-pale);
  overflow: hidden;
}
.jauge-remplie {
  height: 100%;
  width: calc(var(--valeur, 0) * 1%);
  border-radius: inherit;
  background: var(--or);
}
.carte-sombre .jauge,
.tuile-sombre .jauge {
  background: var(--nuit-surface-haute);
}
