/* Composants réutilisables : cartes, badges, tableaux, boutons, onglets */

/* ------------------------------------------------------------------ Cartes */
.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: var(--espace-l);
}

.carte__titre {
  font-size: 16px;
  margin-bottom: var(--espace-m);
  padding-bottom: var(--espace-s);
  border-bottom: 2px solid var(--or);
  display: inline-block;
}

.carte--plate {
  padding: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------ Cartes de KPI */
.kpi {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: var(--espace-m) var(--espace-l);
  display: flex;
  align-items: center;
  gap: var(--espace-m);
  text-align: left;
  width: 100%;
  border-left: 4px solid var(--bleu-vif);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

a.kpi:hover,
button.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--ombre-forte);
  text-decoration: none;
}

.kpi__pastille {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.kpi__pastille svg {
  width: 24px;
  height: 24px;
}

.kpi__valeur {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--bleu-nuit);
}

.kpi__libelle {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--texte);
}

.kpi__detail {
  display: block;
  font-size: 12px;
  color: var(--texte-doux);
}

.kpi__detail:empty {
  display: none;
}

.kpi--vert {
  border-left-color: var(--vert-ok);
}
.kpi--vert .kpi__pastille {
  background: var(--vert-fond);
  color: var(--vert-ok);
}
.kpi--vert .kpi__valeur {
  color: var(--vert-ok);
}

.kpi--orange {
  border-left-color: var(--orange-attention);
}
.kpi--orange .kpi__pastille {
  background: var(--orange-fond);
  color: var(--orange-attention);
}
.kpi--orange .kpi__valeur {
  color: var(--orange-attention);
}

.kpi--rouge {
  border-left-color: var(--rouge-alerte);
}
.kpi--rouge .kpi__pastille {
  background: var(--rouge-fond);
  color: var(--rouge-alerte);
}
.kpi--rouge .kpi__valeur {
  color: var(--rouge-alerte);
}

.kpi--bleu .kpi__pastille {
  background: var(--bleu-info-fond);
  color: var(--bleu-info);
}

.kpi--violet {
  border-left-color: var(--violet);
}
.kpi--violet .kpi__pastille {
  background: var(--violet-fond);
  color: var(--violet);
}

.kpi--or {
  border-left-color: var(--or);
}
.kpi--or .kpi__pastille {
  background: var(--or-clair);
  color: #a97600;
}

/* ------------------------------------------------------------------ Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--rayon-pastille);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge__detail {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--texte-doux);
  margin-top: 2px;
}

.badge--vert {
  background: var(--vert-fond);
  color: var(--vert-ok);
}
.badge--orange {
  background: var(--orange-fond);
  color: var(--orange-attention);
}
.badge--rouge {
  background: var(--rouge-fond);
  color: var(--rouge-alerte);
}
.badge--bleu {
  background: var(--bleu-info-fond);
  color: var(--bleu-info);
}
.badge--gris {
  background: #eef1f6;
  color: var(--texte-doux);
}

/* ---------------------------------------------------------------- Boutons */
.bouton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--rayon-petit);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  background: var(--blanc);
  color: var(--bleu-nuit);
  border-color: var(--bordure-forte);
  transition: background 0.15s ease;
}

.bouton:hover {
  background: var(--bleu-pale);
  text-decoration: none;
}

.bouton--primaire {
  background: var(--bleu-nuit);
  color: var(--blanc);
  border-color: var(--bleu-nuit);
}

.bouton--primaire:hover {
  background: var(--bleu-nuit-clair);
}

.bouton--or {
  background: var(--or);
  color: var(--bleu-nuit);
  border-color: var(--or);
}

.bouton--discret {
  background: transparent;
  border-color: transparent;
  color: var(--bleu-vif);
  padding: 6px 10px;
}

.bouton svg {
  width: 17px;
  height: 17px;
}

.bouton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tableau thead th {
  background: var(--surface);
  text-align: left;
  padding: 14px var(--espace-m);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--texte-doux);
  border-bottom: 2px solid var(--bordure);
  white-space: nowrap;
}

.tableau thead th button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tableau tbody td {
  padding: 12px var(--espace-m);
  border-bottom: 1px solid var(--bordure);
  vertical-align: middle;
}

.tableau tbody tr:hover {
  background: var(--bleu-pale);
}

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

.cellule-adherent {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bleu-pale);
  color: var(--bleu-nuit);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* La photo occupe exactement la même boîte que les initiales : aucun décalage
   de mise en page selon que l'adhérent a une photo ou non. */
img.avatar {
  object-fit: cover;
  background: var(--bleu-pale);
}

.avatar--grand {
  width: 128px;
  height: 128px;
  font-size: 34px;
  border-radius: var(--rayon);
}

.cellule-adherent strong {
  display: block;
  color: var(--bleu-nuit);
  font-size: 14.5px;
}

.cellule-adherent span {
  font-size: 12px;
  color: var(--texte-faible);
}

.texte-secondaire {
  display: block;
  font-size: 12px;
  color: var(--texte-doux);
}

/* --------------------------------------------------------------- Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--espace-m);
  padding: var(--espace-m);
  flex-wrap: wrap;
  border-top: 1px solid var(--bordure);
}

.pagination__pages {
  display: flex;
  gap: 4px;
  margin: 0 auto;
}

.pagination__page {
  min-width: 36px;
  height: 36px;
  border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure);
  background: var(--blanc);
  color: var(--texte);
  font-weight: 600;
}

.pagination__page--actif {
  background: var(--bleu-nuit);
  color: var(--blanc);
  border-color: var(--bleu-nuit);
}

.pagination__page:disabled {
  opacity: 0.4;
}

/* ------------------------------------------------------------------ Alertes */
.alerte {
  display: flex;
  align-items: center;
  gap: var(--espace-m);
  padding: 12px var(--espace-m);
  border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure);
  background: var(--surface);
}

.alerte + .alerte {
  margin-top: var(--espace-s);
}

.alerte__pastille {
  width: 38px;
  height: 38px;
  border-radius: var(--rayon-petit);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.alerte__pastille svg {
  width: 20px;
  height: 20px;
}

.alerte--rouge .alerte__pastille {
  background: var(--rouge-fond);
  color: var(--rouge-alerte);
}
.alerte--orange .alerte__pastille {
  background: var(--orange-fond);
  color: var(--orange-attention);
}
.alerte--vert .alerte__pastille {
  background: var(--vert-fond);
  color: var(--vert-ok);
}
.alerte--bleu .alerte__pastille {
  background: var(--bleu-info-fond);
  color: var(--bleu-info);
}

.alerte strong {
  display: block;
  font-size: 14px;
  color: var(--texte);
}

.alerte span {
  font-size: 12.5px;
  color: var(--texte-doux);
}

.alerte__action {
  margin-left: auto;
}

/* ------------------------------------------------------------------ Onglets */
.onglets {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--bordure);
  overflow-x: auto;
}

.onglet {
  padding: 12px 18px;
  border: 0;
  background: transparent;
  color: var(--texte-doux);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.onglet:hover {
  color: var(--bleu-nuit);
}

.onglet--actif {
  color: var(--bleu-nuit);
  border-bottom-color: var(--bleu-nuit);
}

/* -------------------------------------------------------- Listes de définition */
.definitions {
  display: grid;
  gap: 10px;
}

.definition {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: var(--espace-m);
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--bordure);
}

.definition dt {
  color: var(--texte-doux);
  font-size: 13px;
}

.definition dd {
  margin: 0;
  font-weight: 600;
  color: var(--texte);
}

/* ------------------------------------------------------------------- États */
.etat-vide {
  padding: var(--espace-xl);
  text-align: center;
  color: var(--texte-doux);
}

.etat-vide strong {
  display: block;
  color: var(--bleu-nuit);
  margin-bottom: 4px;
}

.chargement {
  padding: var(--espace-xl);
  text-align: center;
  color: var(--texte-doux);
}

.chargement::after {
  content: '';
  display: block;
  width: 26px;
  height: 26px;
  margin: var(--espace-m) auto 0;
  border: 3px solid var(--bordure);
  border-top-color: var(--bleu-nuit);
  border-radius: 50%;
  animation: tourner 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .chargement::after {
    animation: none;
  }
  .kpi {
    transition: none;
  }
}

/* --------------------------------------------------------------- Notifications */
.notifications {
  position: fixed;
  right: var(--espace-l);
  bottom: var(--espace-l);
  display: flex;
  flex-direction: column;
  gap: var(--espace-s);
  z-index: 100;
  max-width: 380px;
}

.notification {
  background: var(--bleu-nuit);
  color: var(--blanc);
  padding: 12px var(--espace-m);
  border-radius: var(--rayon-petit);
  box-shadow: var(--ombre-forte);
  font-size: 14px;
}

.notification--erreur {
  background: var(--rouge-alerte);
}

.notification--succes {
  background: var(--vert-ok);
}

/* ------------------------------------------------------------- Liste à puces */
.liste-manques {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.liste-manques li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: var(--rayon-petit);
  background: var(--orange-fond);
  color: #7a4406;
}

.liste-manques li[data-bloquant='true'] {
  background: var(--rouge-fond);
  color: #8a1a17;
}
