/* components.css — cartes, indicateurs, tableaux, onglets, tiroir, modale, messages */

/* ============================================================
   CARTE D'ACCUEIL
   ============================================================ */

.welcome-card {
  background: linear-gradient(135deg, var(--bgfi-bleu) 0%, var(--bgfi-bleu-fonce) 100%);
  border-radius: 12px; padding: 1.5rem; color: #fff;
  position: relative; overflow: hidden;
}
.welcome-card::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(145, 155, 121, .18) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-content { position: relative; z-index: 1; }
.welcome-title { font-family: var(--titre); font-size: 1.55rem; font-weight: 600; margin-bottom: .3rem; color: #fff; }
.welcome-subtitle { font-size: .9rem; opacity: .85; margin-bottom: 1.2rem; }
.welcome-stats { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.welcome-stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.welcome-stat-label { font-size: .74rem; opacity: .72; }
.welcome-pastilles { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.pastille {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50px; padding: .25rem .75rem;
  font-size: .7rem; font-weight: 600; color: #fff;
}
.pastille svg { width: 12px; height: 12px; }

/* ============================================================
   CARTES D'INDICATEUR
   ============================================================ */

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }

.kpi-card {
  background: var(--blanc);
  border: 1px solid var(--bord);
  border-radius: 12px; padding: 1.2rem;
  position: relative; overflow: hidden;
  transition: var(--t-normale);
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--bgfi-bleu); opacity: 0; transition: var(--t-normale);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--ombre-md); }
.kpi-card:hover::before { opacity: 1; }
.kpi-card.ok::before      { background: var(--vert); opacity: 1; }
.kpi-card.attention::before { background: var(--ambre); opacity: 1; }
.kpi-card.alerte::before  { background: var(--rouge); opacity: 1; }
.kpi-card.info::before    { background: var(--bgfi-bleu); opacity: 1; }

.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .8rem; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.kpi-icon svg { width: 19px; height: 19px; }
.kpi-card.ok .kpi-icon        { background: rgba(46, 125, 74, .12); color: var(--vert); }
.kpi-card.attention .kpi-icon { background: rgba(201, 162, 39, .14); color: var(--ambre); }
.kpi-card.alerte .kpi-icon    { background: rgba(192, 57, 43, .10); color: var(--rouge); }

.kpi-trend {
  display: flex; align-items: center; gap: .2rem;
  padding: .2rem .5rem; border-radius: 15px;
  font-size: .68rem; font-weight: 700;
}
.kpi-trend.positive { background: rgba(46, 125, 74, .1); color: var(--vert); }
.kpi-trend.negative { background: rgba(192, 57, 43, .1); color: var(--rouge); }
.kpi-trend.neutre   { background: var(--fond); color: var(--txt-clair); }
.kpi-trend svg { width: 11px; height: 11px; }

.kpi-label { font-size: .75rem; color: var(--txt-clair); margin-bottom: .25rem; }
.kpi-value {
  font-size: 1.75rem; font-weight: 700; color: var(--txt-fonce);
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: .72rem; color: var(--txt-clair); margin-top: .2rem; }

/* ============================================================
   CARTES D'ACTION RAPIDE ET DE FONCTIONNALITÉ
   ============================================================ */

.actions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.action-card {
  display: flex; align-items: center; gap: .9rem;
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 12px; padding: 1.1rem;
  transition: var(--t-normale); color: inherit;
}
.action-card:hover {
  transform: translateY(-3px); box-shadow: var(--ombre-md);
  border-color: var(--bgfi-bleu-40); color: inherit;
}
.action-icon {
  width: 46px; height: 46px; min-width: 46px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.action-icon svg { width: 20px; height: 20px; }
.action-icon.vert   { background: rgba(46, 125, 74, .12); color: var(--vert); }
.action-icon.or     { background: rgba(201, 162, 39, .14); color: var(--or); }
.action-icon.violet { background: rgba(142, 68, 173, .12); color: var(--violet); }
.action-icon.orange { background: rgba(230, 126, 34, .12); color: var(--orange); }
.action-info { flex: 1; min-width: 0; }
.action-title { font-size: .88rem; font-weight: 600; color: var(--txt-fonce); }
.action-desc { font-size: .75rem; color: var(--txt-clair); }
.action-arrow { color: var(--txt-estompe); transition: var(--t-rapide); }
.action-card:hover .action-arrow { color: var(--bgfi-bleu); transform: translateX(3px); }
.action-arrow svg { width: 15px; height: 15px; display: block; }

/* Carte de fonctionnalité (référence d'exigence, version, sprint) */
.fonctions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.fonction {
  display: flex; gap: .9rem;
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 12px; padding: 1.1rem;
  transition: var(--t-normale); color: inherit;
}
.fonction:hover { transform: translateY(-2px); box-shadow: var(--ombre-md); border-color: var(--bgfi-bleu-40); color: inherit; }
.fonction .action-icon { width: 42px; height: 42px; min-width: 42px; }
.fonction-titre { font-size: .88rem; font-weight: 600; color: var(--txt-fonce); margin-bottom: .15rem; }
.fonction-texte { font-size: .78rem; color: var(--txt-moyen); }
.fonction-pied { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; align-items: center; }

.jeton {
  font-size: .64rem; font-weight: 600; border-radius: 50px;
  padding: .12rem .55rem; background: var(--fond); color: var(--txt-moyen);
  border: 1px solid var(--bord);
}
.jeton.ref { background: var(--bgfi-bleu-10); color: var(--bgfi-bleu); border-color: transparent; font-family: var(--chiffres); }
.jeton.v1  { background: var(--vert-clair); color: var(--vert); border-color: transparent; }
.jeton.v11 { background: var(--bgfi-bleu-10); color: var(--bgfi-bleu); border-color: transparent; }
.jeton.v2  { background: var(--ambre-clair); color: var(--ambre); border-color: transparent; }
.jeton.v3  { background: var(--fond); color: var(--txt-clair); }

/* ============================================================
   CARTE GÉNÉRIQUE
   ============================================================ */

.carte {
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 12px; overflow: hidden;
}
.carte-head {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--bord);
}
.carte-head h3 { font-size: .95rem; }
.carte-head .actions { margin-left: auto; display: flex; gap: .5rem; }
.carte-body { padding: 1.25rem; }
.carte-foot {
  padding: .85rem 1.25rem; border-top: 1px solid var(--bord);
  background: var(--fond); font-size: .78rem; color: var(--txt-clair);
  display: flex; align-items: center; gap: .75rem;
}

/* ============================================================
   BOUTONS
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.1rem;
  font-family: inherit; font-size: .82rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--fond); color: var(--txt-moyen);
  cursor: pointer; white-space: nowrap;
  transition: var(--t-rapide);
}
.btn:hover { background: var(--bord); color: var(--txt-fonce); }
.btn svg { width: 14px; height: 14px; }
.btn-primaire { background: var(--bgfi-bleu); color: #fff; }
.btn-primaire:hover { background: var(--bgfi-bleu-fonce); color: #fff; }
.btn-secondaire { background: var(--blanc); border-color: var(--bord-moyen); color: var(--bgfi-bleu); }
.btn-secondaire:hover { background: var(--bgfi-bleu-05); color: var(--bgfi-bleu); }
.btn-valider { background: var(--vert); color: #fff; }
.btn-valider:hover { background: #256b3c; color: #fff; }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-danger:hover { background: #9d2f22; color: #fff; }
.btn-petit { padding: .35rem .7rem; font-size: .72rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   ÉTIQUETTES D'ÉTAT
   ============================================================ */

.etiquette {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .6rem; border-radius: 50px;
  font-size: .68rem; font-weight: 600; white-space: nowrap;
}
.etiquette::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.etiquette.neutre { background: var(--fond); color: var(--txt-moyen); }
.etiquette.info   { background: var(--bgfi-bleu-10); color: var(--bgfi-bleu); }
.etiquette.succes { background: var(--vert-clair); color: var(--vert); }
.etiquette.alerte { background: var(--ambre-clair); color: var(--ambre); }
.etiquette.danger { background: var(--rouge-clair); color: var(--rouge); }

/* ============================================================
   ONGLETS
   ============================================================ */

.onglets {
  display: flex; gap: .25rem; overflow-x: auto;
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 12px; padding: .35rem; margin-bottom: 1.25rem;
}
.onglet {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; border: none; background: none;
  font-family: inherit; font-size: .82rem; font-weight: 600;
  color: var(--txt-clair); cursor: pointer; border-radius: 8px;
  white-space: nowrap; transition: var(--t-rapide);
}
.onglet:hover { color: var(--bgfi-bleu); background: var(--bgfi-bleu-05); }
.onglet.active { color: #fff; background: var(--bgfi-bleu); }
.onglet svg { width: 15px; height: 15px; }
.onglet .compteur {
  padding: .05rem .4rem; border-radius: 50px;
  background: var(--fond); color: var(--txt-moyen); font-size: .64rem;
}
.onglet.active .compteur { background: rgba(255, 255, 255, .25); color: #fff; }
.onglet .compteur.alerte { background: var(--rouge); color: #fff; }

/* ============================================================
   BARRE D'OUTILS DE TABLEAU
   ============================================================ */

.table-toolbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .9rem 1.1rem;
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 12px 12px 0 0; border-bottom: none;
}
.toolbar-right { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.search-box { position: relative; min-width: 240px; flex: 1; max-width: 360px; }
.search-box input { padding-left: 2.2rem; padding-top: .5rem; padding-bottom: .5rem; font-size: .82rem; }
.search-box svg {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--txt-estompe); pointer-events: none;
}

.filtre-select {
  padding: .5rem .8rem; font-size: .8rem; min-width: 150px; width: auto;
}

/* ============================================================
   TABLEAU
   ============================================================ */

.table-wrap {
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 0 0 12px 12px; overflow: hidden;
}
.table-scroll { overflow-x: auto; }

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

table.tableau thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bgfi-bleu-05);
  color: var(--txt-clair);
  text-align: left; font-weight: 700;
  font-size: .62rem; text-transform: uppercase; letter-spacing: .08em;
  padding: .7rem .9rem;
  border-bottom: 2px solid var(--bord);
  white-space: nowrap; user-select: none;
}
table.tableau thead th.triable { cursor: pointer; }
table.tableau thead th.triable:hover { color: var(--bgfi-bleu); }
table.tableau thead th .sort { opacity: .35; font-size: .6rem; margin-left: .2rem; }
table.tableau thead th.tri-asc .sort,
table.tableau thead th.tri-desc .sort { opacity: 1; color: var(--bgfi-bleu); }

table.tableau tbody td {
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--bord);
  vertical-align: middle;
}
table.tableau tbody tr { transition: var(--t-rapide); position: relative; }
table.tableau tbody tr.cliquable { cursor: pointer; }
table.tableau tbody tr:hover { background: var(--bgfi-bleu-05); }
table.tableau tbody tr.selectionne { background: var(--bgfi-bleu-10); }
table.tableau tbody tr:last-child td { border-bottom: none; }
table.tableau tbody tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--rouge); }
table.tableau tbody tr.attente td:first-child { box-shadow: inset 3px 0 0 var(--ambre); }

table.tableau .droite { text-align: right; }
table.tableau .vide { text-align: center; color: var(--txt-clair); padding: 3rem 1rem; }
.cell-fort { font-weight: 600; color: var(--txt-fonce); }
.cell-ref { font-family: var(--chiffres); font-size: .76rem; color: var(--bgfi-bleu); font-weight: 600; white-space: nowrap; }
table.tableau td.mono { white-space: nowrap; }
.retard { color: var(--rouge); font-weight: 600; }

/* Cellule « personne » */
.cell-personne { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar-mini {
  width: 32px; height: 32px; min-width: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--bgfi-bleu) 0%, var(--bgfi-bleu-fonce) 100%);
  color: #fff; display: grid; place-items: center;
  font-size: .72rem; font-weight: 700;
}
.avatar-mini.vert { background: linear-gradient(135deg, var(--bgfi-vert) 0%, #74805e 100%); }
.cell-personne .nom { font-weight: 600; font-size: .82rem; }
.cell-personne .meta { font-size: .7rem; color: var(--txt-clair); }

/* Pagination */
.table-pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1.1rem;
  background: var(--fond); border-top: 1px solid var(--bord);
  font-size: .78rem; color: var(--txt-clair);
}
.pagination-controls { display: flex; align-items: center; gap: .25rem; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 .5rem;
  border: 1px solid var(--bord); background: var(--blanc);
  border-radius: 6px; font-size: .76rem; font-weight: 600;
  color: var(--txt-moyen); cursor: pointer; transition: var(--t-rapide);
}
.page-btn:hover:not(:disabled) { background: var(--bgfi-bleu-05); border-color: var(--bgfi-bleu-40); color: var(--bgfi-bleu); }
.page-btn.active { background: var(--bgfi-bleu); border-color: var(--bgfi-bleu); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   TIROIR DE DÉTAIL
   ============================================================ */

.tiroir {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 100%;
  background: var(--blanc); box-shadow: var(--ombre-lg);
  transform: translateX(100%); transition: transform .22s ease-out;
  display: flex; flex-direction: column; z-index: 1100;
}
.tiroir.ouvert { transform: none; }
.tiroir-head {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, var(--bgfi-bleu) 0%, var(--bgfi-bleu-fonce) 100%);
  color: #fff;
}
.tiroir-head h3 { color: #fff; font-family: var(--titre); font-size: 1.15rem; }
.tiroir-head .fermer {
  margin-left: auto; background: rgba(255, 255, 255, .15); border: none;
  color: #fff; width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  display: grid; place-items: center;
}
.tiroir-head .fermer:hover { background: rgba(255, 255, 255, .28); }
.tiroir-head .fermer svg { width: 14px; height: 14px; }
.tiroir-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.tiroir-foot {
  padding: .9rem 1.25rem; border-top: 1px solid var(--bord);
  background: var(--fond); display: flex; gap: .5rem; flex-wrap: wrap;
}

.voile {
  position: fixed; inset: 0; background: rgba(0, 31, 63, .45);
  opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 1050;
}
.voile.visible { opacity: 1; pointer-events: auto; }

/* Liste clé / valeur */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .55rem .9rem; font-size: .83rem; }
.kv dt { color: var(--txt-clair); }
.kv dd { font-weight: 600; word-break: break-word; }

/* ============================================================
   FIL D'ÉTAPES
   ============================================================ */

.etapes { list-style: none; padding: 0 0 0 .3rem; margin: 0; border-left: 2px solid var(--bord); }
.etapes li { position: relative; padding: 0 0 1.1rem 1.25rem; font-size: .82rem; }
.etapes li::before {
  content: ''; position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bord-moyen); border: 2px solid var(--blanc);
}
.etapes li.faite::before { background: var(--vert); }
.etapes li.encours::before { background: var(--bgfi-bleu); box-shadow: 0 0 0 4px var(--bgfi-bleu-20); }
.etapes .horodatage { color: var(--txt-clair); font-size: .72rem; }

/* ============================================================
   MESSAGES ET NOTIFICATIONS
   ============================================================ */

.message {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .85rem 1.1rem; border-radius: 10px;
  font-size: .83rem; margin-bottom: 1rem;
  border-left: 4px solid;
}
.message svg { width: 17px; height: 17px; min-width: 17px; margin-top: .1rem; }
.message.info   { background: var(--bgfi-bleu-05); border-color: var(--bgfi-bleu); color: var(--txt-moyen); }
.message.info svg { color: var(--bgfi-bleu); }
.message.alerte { background: var(--ambre-clair); border-color: var(--ambre); color: var(--txt-moyen); }
.message.alerte svg { color: var(--ambre); }
.message.danger { background: var(--rouge-clair); border-color: var(--rouge); color: var(--txt-moyen); }
.message.danger svg { color: var(--rouge); }
.message.succes { background: var(--vert-clair); border-color: var(--vert); color: var(--txt-moyen); }
.message.succes svg { color: var(--vert); }
.message strong { color: var(--txt-fonce); }

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: .6rem; z-index: 1200; }
.toast {
  background: var(--fond-rail); color: #fff;
  padding: .75rem 1.1rem; border-radius: 10px;
  box-shadow: var(--ombre-lg); font-size: .82rem; max-width: 380px;
  display: flex; gap: .6rem; align-items: flex-start;
  animation: entree .2s ease-out;
}
.toast svg { width: 16px; height: 16px; min-width: 16px; color: var(--bgfi-vert); margin-top: .1rem; }
@keyframes entree { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   MODALE ANIMÉE
   ============================================================ */

.modale {
  position: fixed; inset: 0; z-index: 1150;
  background: rgba(0, 31, 63, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: none; place-items: center; padding: 1rem;
  animation: voile-entre .18s ease-out;
}
.modale.ouverte { display: grid; }
.modale.sortante { animation: voile-sort .16s ease-in forwards; }

.modale-boite {
  background: var(--blanc); border-radius: 16px;
  width: 540px; max-width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--ombre-lg);
  animation: modale-entre .24s cubic-bezier(.16, 1, .3, 1);
}
.modale.sortante .modale-boite { animation: modale-sort .16s ease-in forwards; }

.modale-head {
  display: flex; align-items: center; gap: .85rem;
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--bord);
}
.modale-head h3 { font-family: var(--titre); font-size: 1.25rem; color: var(--bgfi-bleu); flex: 1; }
.modale-head .fermer {
  width: 32px; height: 32px; border-radius: 9px; border: none;
  background: var(--fond); color: var(--txt-clair); cursor: pointer;
  display: grid; place-items: center; transition: var(--t-rapide);
}
.modale-head .fermer:hover { background: var(--bord); color: var(--txt-fonce); }
.modale-head .fermer svg { width: 14px; height: 14px; }

.modale-ico {
  width: 44px; height: 44px; min-width: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.modale-ico svg { width: 20px; height: 20px; }
.modale-ico.danger { background: var(--rouge-clair); color: var(--rouge); }
.modale-ico.alerte { background: var(--ambre-clair); color: var(--ambre); }
.modale-ico.succes { background: var(--vert-clair); color: var(--vert); }
.modale-ico[hidden] { display: none; }

.modale-body { padding: 1.25rem; overflow-y: auto; }
.modale-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--bord); display: flex; justify-content: flex-end; gap: .5rem; }

@keyframes voile-entre { from { opacity: 0; } to { opacity: 1; } }
@keyframes voile-sort  { to { opacity: 0; } }
@keyframes modale-entre {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes modale-sort {
  to { opacity: 0; transform: translateY(8px) scale(.98); }
}

/* ============================================================
   POPOVERS DE L'EN-TÊTE
   ============================================================ */

.header-pop { position: relative; }

.popover {
  position: absolute; top: calc(100% + .55rem); right: 0;
  width: 340px; max-width: calc(100vw - 2rem);
  background: var(--blanc); border: 1px solid var(--bord);
  border-radius: 14px; box-shadow: var(--ombre-lg);
  z-index: 200; overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.97);
  transform-origin: top right;
  transition: opacity .18s ease, transform .18s cubic-bezier(.16, 1, .3, 1), visibility .18s;
}
.popover.ouvert { opacity: 1; visibility: visible; transform: none; }
.popover::before {
  content: ''; position: absolute; top: -6px; right: 18px;
  width: 12px; height: 12px; background: var(--blanc);
  border-left: 1px solid var(--bord); border-top: 1px solid var(--bord);
  transform: rotate(45deg);
}

.popover-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1rem; border-bottom: 1px solid var(--bord);
  background: var(--fond); position: relative;
}
.popover-head strong { font-size: .88rem; }
.popover-head .etiquette { margin-left: auto; }
.popover-head.compte { align-items: center; }
.popover-head.compte strong { display: block; font-size: .85rem; }
.popover-head.compte .muted { font-size: .72rem; word-break: break-all; }
.header-profile-avatar.grand { width: 40px; height: 40px; min-width: 40px; }

.popover-body { max-height: 330px; overflow-y: auto; }

.popover-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 1rem; font-size: .85rem; color: var(--txt-moyen);
  transition: var(--t-rapide);
}
.popover-item:hover { background: var(--bgfi-bleu-05); color: var(--bgfi-bleu); }
.popover-item svg { width: 16px; height: 16px; }

.popover-pied {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1rem; border-top: 1px solid var(--bord);
  background: var(--fond); font-size: .82rem; font-weight: 600;
  color: var(--bgfi-bleu); transition: var(--t-rapide);
}
.popover-pied:hover { background: var(--bgfi-bleu-05); }
.popover-pied.danger { color: var(--rouge); }
.popover-pied.danger:hover { background: var(--rouge-clair); }
.popover-pied svg { width: 15px; height: 15px; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */

.notif {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--bord);
  transition: var(--t-rapide); color: inherit;
}
.notif:last-child { border-bottom: none; }
a.notif:hover { background: var(--bgfi-bleu-05); color: inherit; }
.notif.non-lue { background: var(--bgfi-bleu-05); }
.notif.non-lue::after {
  content: ''; width: 8px; height: 8px; min-width: 8px; border-radius: 50%;
  background: var(--bgfi-bleu); margin-top: .35rem;
}
.notif-ico {
  width: 34px; height: 34px; min-width: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.notif-ico svg { width: 16px; height: 16px; }
.notif-ico.alerte { background: var(--ambre-clair); color: var(--ambre); }
.notif-ico.succes { background: var(--vert-clair); color: var(--vert); }
.notif-ico.danger { background: var(--rouge-clair); color: var(--rouge); }
.notif-txt { flex: 1; min-width: 0; font-size: .82rem; }
.notif-txt strong { display: block; font-size: .84rem; color: var(--txt-fonce); }
.notif-txt > span { display: block; color: var(--txt-clair); }
.notif-txt .horodatage { font-size: .72rem; color: var(--txt-estompe); margin-top: .2rem; }
.notif > .horodatage { font-size: .74rem; color: var(--txt-estompe); white-space: nowrap; }
.notif-liste .notif { padding: 1rem 1.25rem; }

/* ============================================================
   PROFIL
   ============================================================ */

.profil-entete {
  background: linear-gradient(135deg, var(--bgfi-bleu) 0%, var(--bgfi-bleu-fonce) 100%);
  border-radius: 16px; padding: 1.75rem; color: #fff;
  position: relative; overflow: hidden; margin-bottom: 1.5rem;
}
.profil-entete::before {
  content: ''; position: absolute; top: -55%; right: -12%;
  width: 55%; height: 210%; background: rgba(255, 255, 255, .06); transform: rotate(28deg);
}
.profil-contenu { display: flex; align-items: center; gap: 1.75rem; position: relative; z-index: 1; flex-wrap: wrap; }

.profil-avatar {
  width: 104px; height: 104px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bgfi-vert) 0%, #6d7a55 100%);
  display: grid; place-items: center;
  font-size: 2.3rem; font-weight: 700; color: #fff;
  border: 4px solid rgba(255, 255, 255, .28);
  position: relative;
}
.avatar-edit {
  position: absolute; bottom: 2px; right: 2px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: #fff; color: var(--bgfi-bleu); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--ombre-md);
  transition: var(--t-rapide);
}
.avatar-edit:hover { transform: scale(1.08); }
.avatar-edit svg { width: 15px; height: 15px; }

.profil-info h2 { color: #fff; font-family: var(--titre); font-size: 1.7rem; margin-bottom: .2rem; }
.profil-info p { color: rgba(255, 255, 255, .82); margin-bottom: .8rem; }
.profil-badges { display: flex; gap: .5rem; flex-wrap: wrap; }
.profil-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .22);
  color: #fff; padding: .28rem .7rem; border-radius: 50px;
  font-size: .72rem; font-weight: 600;
}
.profil-badge svg { width: 12px; height: 12px; }

.profil-stats { margin-left: auto; display: flex; gap: 2rem; }
.profil-stat { text-align: center; }
.profil-stat .valeur { font-size: 1.6rem; font-weight: 700; }
.profil-stat .libelle { font-size: .74rem; opacity: .8; }

/* ============================================================
   FORMULAIRES ET PARAMÈTRES
   ============================================================ */

.settings-ico {
  width: 44px; height: 44px; min-width: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.settings-ico svg { width: 19px; height: 19px; }
.settings-ico.vert   { background: var(--vert-clair); color: var(--vert); }
.settings-ico.violet { background: rgba(142, 68, 173, .12); color: var(--violet); }
.settings-ico.or     { background: rgba(201, 162, 39, .14); color: var(--ambre); }
.settings-ico.rouge  { background: var(--rouge-clair); color: var(--rouge); }

.form-carte, .settings-section { margin-bottom: 1.25rem; }
.settings-section.danger { border-color: rgba(192, 57, 43, .35); }

.form-grille { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; }
.form-grille .groupe-champ { margin-bottom: 0; }
.form-grille .groupe-champ.large { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

.setting-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1.25rem;
  padding: .95rem 0; border-bottom: 1px solid var(--bord);
}
.setting-item:last-of-type { border-bottom: none; }
.setting-label h4 { font-size: .9rem; font-weight: 600; margin-bottom: .15rem; }
.setting-label p { font-size: .78rem; margin: 0; }
.setting-item .filtre-select { min-width: 190px; width: auto; }

/* Interrupteur */
.toggle { position: relative; width: 48px; height: 26px; min-width: 48px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-piste {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bord-moyen); border-radius: 26px;
  transition: background .25s ease;
}
.toggle-piste::before {
  content: ''; position: absolute;
  height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .25s cubic-bezier(.16, 1, .3, 1);
}
.toggle input:checked + .toggle-piste { background: var(--bgfi-bleu); }
.toggle input:checked + .toggle-piste::before { transform: translateX(22px); }
.toggle input:disabled + .toggle-piste { opacity: .55; cursor: not-allowed; }
.toggle input:focus-visible + .toggle-piste { outline: 2px solid var(--bgfi-bleu); outline-offset: 2px; }

/* ============================================================
   DIVERS
   ============================================================ */

.jauge { height: 8px; background: var(--bord); border-radius: 4px; overflow: hidden; }
.jauge > span { display: block; height: 100%; background: var(--bgfi-vert); border-radius: 4px; }
.jauge.bleue > span { background: var(--bgfi-bleu); }
.jauge.rouge > span { background: var(--rouge); }

.liste-simple { list-style: none; padding: 0; }
.liste-simple li {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 0; border-bottom: 1px solid var(--bord); font-size: .83rem;
}
.liste-simple li:last-child { border-bottom: none; }
.liste-simple .puce {
  width: 32px; height: 32px; min-width: 32px; border-radius: 8px;
  display: grid; place-items: center; background: var(--bgfi-bleu-10); color: var(--bgfi-bleu);
}
.liste-simple .puce svg { width: 15px; height: 15px; }
.liste-simple .horodatage { margin-left: auto; font-size: .72rem; color: var(--txt-clair); white-space: nowrap; }

.service-etat { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--bord); font-size: .83rem; }
.service-etat:last-child { border-bottom: none; }
.service-etat .nom { font-weight: 600; }
.service-etat .mesures { margin-left: auto; font-size: .72rem; color: var(--txt-clair); white-space: nowrap; }

/* ============================================================
   ANIMATIONS D'ENTRÉE
   ============================================================ */

@keyframes monte {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.kpi-card, .action-card, .fonction, .carte, .welcome-card, .profil-entete, .table-toolbar {
  animation: monte .32s cubic-bezier(.16, 1, .3, 1) both;
}
.kpi-card:nth-child(2), .action-card:nth-child(2), .fonction:nth-child(2) { animation-delay: .04s; }
.kpi-card:nth-child(3), .action-card:nth-child(3), .fonction:nth-child(3) { animation-delay: .08s; }
.kpi-card:nth-child(4), .action-card:nth-child(4), .fonction:nth-child(4) { animation-delay: .12s; }
.fonction:nth-child(5) { animation-delay: .16s; }
.fonction:nth-child(6) { animation-delay: .2s; }

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .action-card, .fonction, .carte, .welcome-card, .profil-entete, .table-toolbar,
  .modale, .modale-boite, .toast { animation: none !important; }
}

@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .actions-grid, .fonctions-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .kpi-card { padding: .9rem; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-head { margin-bottom: .5rem; }
  .kpi-icon { width: 34px; height: 34px; border-radius: 8px; }
  .kpi-icon svg { width: 16px; height: 16px; }
  .welcome-title { font-size: 1.3rem; }
  .welcome-stats { gap: 1.25rem; }
  .welcome-stat-value { font-size: 1.4rem; }
  .kv { grid-template-columns: 1fr; gap: .2rem .9rem; }
  .kv dd { margin-bottom: .5rem; }
  .welcome-stats { gap: 1.5rem; }
  .tiroir { width: 100%; }
  .profil-contenu { flex-direction: column; align-items: flex-start; gap: 1.1rem; }
  .profil-stats { margin-left: 0; gap: 1.5rem; }
  .form-grille { grid-template-columns: 1fr; }
  .setting-item { flex-direction: column; align-items: flex-start; gap: .7rem; }
  .setting-item .filtre-select { width: 100%; }
  .popover { width: calc(100vw - 2rem); position: fixed; right: 1rem; top: calc(var(--entete) + .4rem); }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}
