/* Composants (src/components/) : boutons, champs, cartes, bandeaux, roue, état vide, tableau adaptatif,
   fenêtre modale, notifications, pastilles, onglets. Cibles tactiles de 44 px au moins. */

.icone {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

/* ---------- boutons ---------- */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--rayon-petit);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.bouton--pleine-largeur {
  width: 100%;
}

/* contenu d'un <Bouton> : pictogramme et texte sur une ligne */
.bouton__texte {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.bouton--primaire {
  background: var(--bleu);
  color: #fff;
}

.bouton--primaire:hover:not(:disabled) {
  background: var(--bleu-fonce);
  color: #fff;
}

.bouton--secondaire {
  background: var(--fond);
  border-color: var(--bord-fort);
  color: var(--bleu-fonce);
}

.bouton--secondaire:hover:not(:disabled) {
  background: var(--survol);
  color: var(--bleu-fonce);
}

.bouton--discret {
  background: transparent;
  color: var(--bleu);
  padding-inline: 0.5rem;
  justify-self: start;
}

.bouton--discret:hover:not(:disabled) {
  background: var(--survol);
  color: var(--bleu-fonce);
}

.bouton--danger {
  background: var(--mauvais);
  color: #fff;
}

.bouton--danger:hover:not(:disabled) {
  background: #991b1b;
}

.bouton:disabled {
  opacity: 0.65;
}

.bouton[aria-busy="true"] {
  opacity: 0.85;
  cursor: progress;
}

.bouton-icone {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--rayon-petit);
  background: transparent;
  color: var(--encre-2);
}

.bouton-icone:hover {
  background: var(--survol);
  color: var(--encre);
}

.bouton-icone .icone {
  width: 1.4rem;
  height: 1.4rem;
}

.lien-bouton {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--bleu);
  font-weight: 600;
}

.lien-bouton:hover {
  color: var(--bleu-fonce);
  text-decoration: underline;
}

/* ---------- formulaires ---------- */
.formulaire {
  display: grid;
  gap: 1rem;
}

.champ {
  display: grid;
  gap: 0.35rem;
}

.champ__libelle {
  font-weight: 600;
  color: var(--encre);
}

.champ__requis {
  color: var(--mauvais);
}

.champ__cadre {
  position: relative;
  display: flex;
}

.champ__saisie {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--bord-fort);
  border-radius: var(--rayon-petit);
  background: var(--fond);
  color: var(--encre);
  /* 16 px au moins : pas de zoom automatique sur iPhone */
  font-size: max(1rem, 16px);
}

.champ__saisie:hover:not(:disabled) {
  border-color: var(--bleu);
}

.champ__saisie:focus-visible {
  outline: var(--anneau);
  outline-offset: 1px;
  border-color: var(--bleu-fonce);
}

.champ__saisie:disabled {
  background: var(--segment);
  color: var(--discret);
}

.champ__cadre:has(.champ__reveler) .champ__saisie {
  padding-right: 6rem;
}

.champ__reveler {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(-50%);
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--bleu);
  font-size: 0.9rem;
  font-weight: 600;
}

.champ__reveler:hover {
  background: var(--survol);
}

.champ__saisie--code {
  max-width: 13rem;
  font-family: var(--police-mono);
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  text-align: center;
  padding-left: calc(0.8rem + 0.35em);
}

.champ__saisie--liste {
  appearance: none;
  padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--encre-2) 50%),
    linear-gradient(135deg, var(--encre-2) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 55%, calc(100% - 0.8rem) 55%;
  background-size: 0.35rem 0.35rem;
  background-repeat: no-repeat;
}

.champ__aide {
  font-size: 0.875rem;
  color: var(--discret);
}

.champ__erreur {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--mauvais);
}

.champ--erreur .champ__saisie {
  border-color: var(--mauvais);
  box-shadow: inset 0 0 0 1px var(--mauvais);
}

.champ__avertissement {
  margin-top: -0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--attention);
}

.case {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.case__saisie {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  accent-color: var(--bleu);
}

.case__libelle {
  font-weight: 550;
  cursor: pointer;
}

.barre-outils {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 40em) {
  .barre-outils {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: end;
  }
}

/* ---------- cartes ---------- */
.carte {
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 1rem;
}

@media (min-width: 40em) {
  .carte {
    padding: 1.25rem 1.5rem;
  }
}

.carte__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.carte__titre {
  font-size: 1.1rem;
}

/* ---------- en-tête de page ---------- */
.en-tete-page {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.en-tete-page__titre {
  font-size: 1.5rem;
}

.en-tete-page__sous-titre {
  margin-top: 0.25rem;
  color: var(--encre-2);
  max-width: 60ch;
}

.en-tete-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (min-width: 40em) {
  .en-tete-page__titre {
    font-size: 1.75rem;
  }
}

/* ---------- bandeaux ---------- */
.alerte {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border: 1px solid;
  border-radius: var(--rayon-petit);
}

.alerte > .icone {
  margin-top: 0.15rem;
}

.alerte__titre {
  font-weight: 700;
}

.alerte--info {
  background: var(--info-fond);
  border-color: #b9d0ec;
  color: var(--bleu-fonce);
}

.alerte--succes {
  background: var(--bon-fond);
  border-color: #9fd8bf;
  color: #065f46;
}

.alerte--attention {
  background: var(--attention-fond);
  border-color: #f0d08c;
  color: var(--attention);
}

.alerte--erreur {
  background: var(--mauvais-fond);
  border-color: #f2b8b8;
  color: var(--mauvais);
}

.alerte + .bouton {
  margin-top: 0.75rem;
}

/* ---------- roue de chargement ---------- */
.spinner {
  display: inline-block;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--selection);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: tourner 0.8s linear infinite;
}

.spinner--petit {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
  border-color: rgb(255 255 255 / 40%);
  border-top-color: currentcolor;
}

.bouton--secondaire .spinner--petit,
.bouton--discret .spinner--petit {
  border-color: var(--selection);
  border-top-color: var(--bleu);
}

.spinner--grand {
  width: 2.5rem;
  height: 2.5rem;
  border-width: 4px;
}

@keyframes tourner {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.chargement {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  color: var(--encre-2);
}

.chargement--pleine-page {
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

/* ---------- état vide ---------- */
.etat-vide {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  text-align: center;
}

.etat-vide__icone {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.25rem;
  border-radius: 50%;
  background: var(--bleu-pale);
  color: var(--bleu);
}

.etat-vide__icone .icone {
  width: 1.6rem;
  height: 1.6rem;
}

.etat-vide__titre {
  font-weight: 650;
  font-size: 1.05rem;
}

.etat-vide__texte {
  max-width: 46ch;
  color: var(--encre-2);
}

.etat-vide__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ---------- pastilles d'état ---------- */
.pastille {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}

.pastille--succes {
  background: var(--bon-fond);
  color: #065f46;
}

.pastille--attention {
  background: var(--attention-fond);
  color: var(--attention);
}

.pastille--erreur {
  background: var(--mauvais-fond);
  color: var(--mauvais);
}

.pastille--info {
  background: var(--info-fond);
  color: var(--bleu-fonce);
}

/* ---------- tableau adaptatif ---------- */
.tableau-adaptatif {
  overflow-x: auto;
}

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.tableau th {
  padding: 0.6rem 0.75rem;
  background: var(--entete);
  color: var(--encre-2);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.tableau th:first-child {
  border-top-left-radius: var(--rayon-petit);
}

.tableau th:last-child {
  border-top-right-radius: var(--rayon-petit);
}

.tableau td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--trait);
  vertical-align: top;
}

.tableau tbody tr:nth-child(even) {
  background: var(--fond-doux);
}

@media (hover: hover) and (min-width: 48em) {
  .tableau tbody tr:hover {
    background: var(--survol);
  }
}

.tableau__cellule--nombre {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* écran étroit : une carte par ligne, le titre de la colonne devant chaque valeur */
@media (max-width: 47.99em) {
  .tableau,
  .tableau tbody,
  .tableau tr,
  .tableau td {
    display: block;
    width: 100%;
  }

  .tableau thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .tableau tbody {
    display: grid;
    gap: 0.75rem;
  }

  .tableau tr,
  .tableau tbody tr:nth-child(even) {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--bord);
    border-radius: var(--rayon-petit);
    background: var(--fond);
  }

  .tableau td {
    display: grid;
    grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--trait);
    text-align: left;
  }

  .tableau td:last-child {
    border-bottom: 0;
  }

  .tableau td::before {
    content: attr(data-label);
    color: var(--discret);
    font-size: 0.875rem;
    font-weight: 600;
    overflow-wrap: anywhere;
  }

  /* pastille à sa taille, pas étirée sur la colonne */
  .tableau td > * {
    justify-self: start;
  }
}

.cellule-compte {
  display: grid;
  min-width: 0;
}

.cellule-compte__nom {
  font-weight: 600;
}

.cellule-compte__email {
  color: var(--discret);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* ---------- fenêtre modale ---------- */
.fenetre-voile {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgb(15 30 51 / 50%);
}

.fenetre {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  transform: translateX(-50%);
  background: var(--fond);
  border-radius: var(--rayon) var(--rayon) 0 0;
  box-shadow: var(--ombre-forte);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 40em) {
  .fenetre {
    top: 50%;
    bottom: auto;
    width: min(36rem, calc(100vw - 2rem));
    transform: translate(-50%, -50%);
    border-radius: var(--rayon);
  }
}

.fenetre__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.75rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--trait);
}

.fenetre__titre {
  font-size: 1.2rem;
  /* titre long sans espace (nom de dossier…) : il passe à la ligne, le bouton de fermeture reste visible */
  min-width: 0;
  overflow-wrap: anywhere;
}

.fenetre__corps {
  overflow-y: auto;
  padding: 1.25rem;
  /* contenu long : le corps défile, l'en-tête et les boutons du pied restent visibles */
  flex: 1 1 auto;
  min-height: 0;
}

.fenetre__entete,
.fenetre__pied {
  flex-shrink: 0;
}

.fenetre__pied {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--trait);
}

/* ---------- notifications ---------- */
.notifications {
  position: fixed;
  z-index: 95;
  left: 0.75rem;
  right: 0.75rem;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}

@media (min-width: 40em) {
  .notifications {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 24rem;
  }
}

.notification {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.4rem 0.4rem 0.9rem;
  border: 1px solid var(--bord);
  border-left: 4px solid var(--bleu);
  border-radius: var(--rayon-petit);
  background: var(--fond);
  box-shadow: var(--ombre-forte);
  pointer-events: auto;
}

.notification--succes {
  border-left-color: var(--bon);
}

.notification--succes > .icone {
  color: var(--bon);
}

.notification--attention {
  border-left-color: var(--attention);
}

.notification--attention > .icone {
  color: var(--attention);
}

.notification--erreur {
  border-left-color: var(--mauvais);
}

.notification--erreur > .icone {
  color: var(--mauvais);
}

.notification--info > .icone {
  color: var(--bleu);
}

.notification__texte {
  flex: 1;
  font-weight: 550;
}

/* ---------- onglets (administration) ---------- */
.onglets {
  margin: -0.25rem 0 1.25rem;
  border-bottom: 1px solid var(--bord);
  overflow-x: auto;
}

.onglets__liste {
  list-style: none;
  display: flex;
  gap: 0.25rem;
}

.onglets__lien {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border-bottom: 3px solid transparent;
  color: var(--encre-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.onglets__lien:hover {
  color: var(--bleu-fonce);
  background: var(--survol);
}

.onglets__lien[aria-current="page"] {
  color: var(--bleu-fonce);
  border-bottom-color: var(--bleu);
}

/* ---------- chiffres clés en cartes (haut des pages) ---------- */
.indicateurs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.85rem;
}

.indicateur {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.95rem 1.15rem;
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
}

.indicateur__libelle {
  color: var(--discret);
  font-size: 0.8rem;
  font-weight: 650;
}

.indicateur__valeur {
  color: var(--encre);
  font-size: 1.75rem;
  font-weight: 750;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.indicateur__valeur--alerte {
  color: var(--mauvais);
}

.indicateur__valeur--date {
  font-size: 1.15rem;
  line-height: 1.6;
}

.indicateur__texte {
  color: var(--discret);
  font-size: 0.88rem;
}

.indicateur progress {
  width: 100%;
  height: 0.45rem;
}

/* ---------- filtre en onglets avec compteurs ---------- */
.onglets-filtre {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--bord);
}

/* dans les actions d'un en-tête de page (Utilisation), à côté des boutons */
.en-tete-page__actions .onglets-filtre {
  margin-bottom: 0;
  align-self: center;
}

.onglets-filtre__onglet {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  margin-bottom: -1px;
  padding: 0 0.1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--discret);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.onglets-filtre__onglet:hover {
  color: var(--encre);
}

.onglets-filtre__onglet[aria-pressed="true"] {
  border-bottom-color: var(--bleu);
  color: var(--bleu-fonce);
}

.onglets-filtre__onglet:focus-visible {
  outline: var(--anneau);
  outline-offset: 2px;
}

.onglets-filtre__nombre {
  min-width: 1.5rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--fond-doux);
  border: 1px solid var(--trait);
  color: var(--encre-2);
  font-size: 0.78rem;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.onglets-filtre__onglet[aria-pressed="true"] .onglets-filtre__nombre {
  background: var(--bleu-pale);
  border-color: transparent;
  color: var(--bleu-fonce);
}

/* déconnexion en attente du serveur */
.deconnexion-en-cours {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(-50%);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: var(--fond);
  box-shadow: var(--ombre-forte);
  color: var(--encre-2);
  font-size: 0.9rem;
  font-weight: 600;
}
