/* ==========================================================================
   Veille du PC — feuille de style de la page servie par le VPS
   Prolonge le langage de la console des agents : calme et nette, polices du
   système, une couleur d'accent, et les couleurs à sens fixe : vert = sain,
   ambre = en attente / à regarder, rouge = grave.
   Ici s'ajoute une règle : le pointillé gris = « la page ne sait pas ».

   Sommaire
     1. Jetons               6. À faire             10. Écran large
     2. Socle                7. Alertes             11. Mouvement
     3. Bandeau              8. Journal
     4. Composants repris    9. Fiche de dépannage
     5. État
   ========================================================================== */

/* ---------- 1. Jetons ----------
   Copie des jetons de la console (logiciel/pc_agents/web/static/style.css, section 1), mêmes
   valeurs. La page vit sur une autre origine que la console : rien n'est partagé, c'est une copie
   à tenir à jour. Deux jetons de plus : --grave-plein et --sur-grave (le bloc « PC muet »). */
:root {
  color-scheme: light dark;

  --fond: #f3f4f6;
  --surface: #ffffff;
  --creux: #eef0f3;
  --bandeau: #ffffff;         /* = theme-color de index.html */
  --texte: #1a1f26;
  --doux: #55606c;
  --bord: #dde1e6;
  --bord-fort: #8a939f;
  --survol: #eceff3;
  --accent: #1f4b82;
  --accent-texte: #ffffff;
  --accent-doux: #e4edf8;
  --focus: #2f6fd0;
  --ok: #1a6e3c;
  --ok-fond: #e3f3e8;
  --ok-plein: #1a6e3c;
  --sur-ok: #ffffff;
  --grave: #b3261e;
  --grave-fond: #fbeae8;
  --grave-plein: #b3261e;     /* fond du bloc « PC muet » */
  --sur-grave: #ffffff;       /* texte posé dessus */
  --attention: #8a5a00;
  --attention-fond: #fcf0d4;
  --attention-plein: #a35a00;
  --sur-attention: #ffffff;
  --attention-bord: #dfb14e;
  --marque: #1d3557;
  --sur-marque: #e9edf3;
  --ombre-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --ombre-2: 0 6px 20px rgba(16, 24, 40, 0.14);

  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-mini: 0.75rem;
  --t-petit: 0.8125rem;
  --t-aide: 0.875rem;
  --t-corps: 1rem;
  --t-lecture: 1.0625rem;

  --e1: 4px;
  --e2: 8px;
  --e3: 12px;
  --e4: 16px;
  --e5: 24px;
  --e6: 32px;

  --r1: 6px;
  --r2: 10px;
  --r3: 14px;
  --rond: 999px;

  --bandeau-h: 56px;
  --colonne: 32rem;           /* une seule colonne, étroite : c'est une page de téléphone */
  --marge: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #101418;
    --surface: #191e25;
    --creux: #12161b;
    --bandeau: #151a20;
    --texte: #e7eaee;
    --doux: #9ca6b2;
    --bord: #2a313a;
    --bord-fort: #657080;
    --survol: #222932;
    --accent: #8fb6ee;
    --accent-texte: #0c1622;
    --accent-doux: #1b2a40;
    --focus: #9cc2ff;
    --ok: #8fd3a5;
    --ok-fond: #14281b;
    --ok-plein: #8fd3a5;
    --sur-ok: #0b1a10;
    --grave: #f3aaa5;
    --grave-fond: #33191a;
    --grave-plein: #c7352b;   /* reste un rouge franc en sombre : c'est l'alarme de la page */
    --sur-grave: #ffffff;
    --attention: #eac26d;
    --attention-fond: #2c230f;
    --attention-plein: #eac26d;
    --sur-attention: #241800;
    --attention-bord: #75601f;
    --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ombre-2: 0 6px 20px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- 2. Socle ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* L'attribut hidden doit toujours gagner : page.js montre et cache les blocs avec lui, et
   plusieurs de ces blocs reçoivent ici un display (flex, grid). Ne jamais retirer cette règle. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--fond);
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  color: var(--texte);
  font: 400 var(--t-corps)/1.5 var(--police);
}
main {
  flex: 1 1 auto;
  align-self: center;
  width: 100%;
  max-width: calc(var(--colonne) + 2 * var(--marge));
  padding: var(--e4) max(var(--marge), env(safe-area-inset-right)) calc(var(--e5) + env(safe-area-inset-bottom)) max(var(--marge), env(safe-area-inset-left));
}

h1, h2, h3 { line-height: 1.25; }
h3 { font-size: var(--t-corps); font-weight: 650; margin: var(--e4) 0 var(--e1); }
p { margin: 0 0 var(--e3); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Texte pour VoiceOver seulement */
.pour-lecteur {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- 3. Bandeau ---------- */
.bandeau {
  position: sticky; top: 0; z-index: 30;
  flex: none;
  padding-top: env(safe-area-inset-top);      /* l'encoche */
  background: var(--bandeau);
  border-bottom: 1px solid var(--bord);
}
.bandeau-dedans {
  display: flex; align-items: center; gap: var(--e3);
  height: var(--bandeau-h);
  width: 100%; max-width: calc(var(--colonne) + 2 * var(--marge)); margin: 0 auto;
  padding: 0 max(var(--e2), env(safe-area-inset-right)) 0 max(var(--marge), env(safe-area-inset-left));
}
.marque {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--marque); color: var(--sur-marque);
}
.marque svg { width: 22px; height: 22px; display: block; }
.bandeau h1 {
  flex: 1 1 auto; min-width: 0; margin: 0;
  font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bandeau button { flex: none; }
button.icone-seule { min-width: 44px; padding: 0; }
button.icone-seule svg { width: 22px; height: 22px; }

/* Trait bleu qui glisse sous le bandeau pendant une lecture ; n'apparaît qu'après 0,3 s. */
.chargement {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  overflow: hidden; pointer-events: none;
  animation: attente-debut 0.3s linear;
}
.chargement::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: var(--accent); border-radius: var(--rond);
  animation: chargement-glisse 1.2s ease-in-out infinite;
}
@keyframes attente-debut { from { opacity: 0; } 99% { opacity: 0; } to { opacity: 1; } }
@keyframes chargement-glisse {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

/* ---------- 4. Composants repris de la console ---------- */

/* Boutons : .principal (plein), ordinaire (contour), .discret (texte seul). 44 px au moins. */
button, a.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  min-height: 44px; padding: 9px var(--e4);
  font: inherit; font-size: var(--t-corps); font-weight: 600; line-height: 1.25; text-align: center;
  text-decoration: none;
  color: var(--texte); background: var(--surface);
  border: 1px solid var(--bord-fort); border-radius: var(--r2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
button svg, a.bouton svg { flex: none; display: block; width: 20px; height: 20px; }
button.principal, a.bouton.principal {
  background: var(--accent); color: var(--accent-texte); border-color: var(--accent);
}
button.discret, a.bouton.discret {
  background: transparent; border-color: transparent; color: var(--accent);
}
button.grand { min-height: 52px; }
button:active:not(:disabled), a.bouton:active { opacity: 0.75; }
button:disabled { opacity: 0.45; cursor: default; }
@media (hover: hover) {
  button:hover:not(:disabled), a.bouton:hover { background: var(--survol); }
  button.principal:hover:not(:disabled), a.bouton.principal:hover { background: var(--accent); opacity: 0.9; }
  button.discret:hover:not(:disabled), a.bouton.discret:hover { background: var(--accent-doux); }
}

/* Rangée de boutons ; .pleine : les boutons se partagent toute la largeur. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); margin: var(--e3) 0 0; }
.actions.pleine > * { flex: 1 1 auto; }

/* Cartes */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r3);
  padding: var(--e4); margin: 0 0 var(--e4);
  box-shadow: var(--ombre-1);
}
.carte > :first-child { margin-top: 0; }
.carte > :last-child { margin-bottom: 0; }

/* Textes secondaires */
.aide { color: var(--doux); font-size: var(--t-aide); }
.detail { color: var(--doux); font-size: var(--t-petit); }
.etiquette { color: var(--doux); font-size: var(--t-aide); font-weight: 600; }

/* Pastilles */
.badge {
  display: inline-flex; align-items: center; gap: var(--e1);
  padding: 2px 9px; border-radius: var(--rond);
  background: var(--creux); color: var(--doux); border: 1px solid var(--bord);
  font-size: var(--t-mini); font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge.ok { background: var(--ok-fond); color: var(--ok); border-color: transparent; }
.badge.attention { background: var(--attention-fond); color: var(--attention); border-color: transparent; }
.badge.grave { background: var(--grave-fond); color: var(--grave); border-color: transparent; }

/* Point de couleur devant une ligne d'état ou d'événement */
.point {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--bord-fort);
}
.point.ok { background: var(--ok); }
.point.attention { background: var(--attention-plein); }
.point.grave { background: var(--grave); }

/* Bloc à barre gauche (comme les alertes de la vue État de la console) */
.bloc {
  margin: var(--e3) 0; padding: var(--e2) var(--e3);
  border-left: 4px solid var(--bord-fort); border-radius: var(--r1);
  background: var(--creux);
  font-size: var(--t-aide); font-weight: 600;
}
.bloc.attention { background: var(--attention-fond); color: var(--attention); border-left-color: var(--attention); }
.bloc.grave { background: var(--grave-fond); color: var(--grave); border-left-color: var(--grave); }

/* Message d'état : reste en vue sous le bandeau */
.message {
  position: sticky; top: calc(env(safe-area-inset-top) + var(--bandeau-h) + var(--e2)); z-index: 20;
  display: flex; align-items: flex-start; gap: var(--e1);
  margin: 0 0 var(--e3); padding: 0 0 0 14px;
  background: var(--surface); color: var(--texte);
  border: 1px solid var(--bord); border-left: 4px solid var(--accent); border-radius: var(--r2);
  box-shadow: var(--ombre-2);
  overflow-wrap: anywhere;
}
.message-texte { flex: 1 1 auto; min-width: 0; padding: var(--e3) 0; }
.message > .fermer {
  flex: none; min-width: 44px; min-height: 44px; margin: 2px; padding: 0;
  background: transparent; border-color: transparent; color: inherit;
}
.message > .fermer svg { width: 18px; height: 18px; }

/* Titre de section : petite étiquette en capitales, au-dessus de chaque bloc */
.titre-section {
  margin: var(--e5) var(--e1) var(--e2);
  color: var(--doux);
  font-size: var(--t-petit); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}

/* ---------- 5. État ----------
   Quatre silhouettes, reconnaissables sans la couleur :
     ok                 bloc teinté vert, disque plein, coche ;
     retard, prevu      bloc teinté ambre à liseré, horloge ou flèche de redémarrage ;
     muet               bloc PLEIN rouge, texte blanc, point d'exclamation (le seul bloc plein) ;
     hors-ligne, vps    cadre en pointillé, sans fond, point d'interrogation : « on ne sait pas » ;
     attente            carte neutre, trois points.
   Jamais de vert sans une lecture récente du VPS (page.js, vue). */
.etat {
  --titre: var(--texte);
  --disque: var(--creux);
  --sur-disque: var(--doux);
  --piste: var(--surface);
  margin: 0 0 var(--e2);
  padding: var(--e5) var(--e4) var(--e4);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r3);
}
body[data-etat="ok"] .etat {
  --titre: var(--ok); --disque: var(--ok-plein); --sur-disque: var(--sur-ok);
  background: var(--ok-fond); border-color: transparent;
}
body[data-etat="retard"] .etat,
body[data-etat="prevu"] .etat {
  --titre: var(--attention); --disque: var(--attention-plein); --sur-disque: var(--sur-attention);
  background: var(--attention-fond); border-color: var(--attention-bord);
}
body[data-etat="muet"] .etat {
  --titre: var(--sur-grave); --disque: var(--sur-grave); --sur-disque: var(--grave-plein);
  background: var(--grave-plein); border-color: var(--grave-plein); color: var(--sur-grave);
  padding-bottom: var(--e5);
}
body[data-etat="hors-ligne"] .etat,
body[data-etat="vps"] .etat {
  background: transparent; border: 2px dashed var(--bord-fort);
}

/* Le signe : un disque de 64 px, une seule icône visible à la fois */
.signe {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; margin: 0 auto var(--e3);
  border-radius: 50%;
  background: var(--disque); color: var(--sur-disque);
}
body[data-etat="hors-ligne"] .signe,
body[data-etat="vps"] .signe { background: transparent; border: 2px solid var(--bord-fort); }
.signe svg { display: none; width: 36px; height: 36px; }
body[data-etat="ok"] .i-ok,
body[data-etat="retard"] .i-retard,
body[data-etat="prevu"] .i-prevu,
body[data-etat="muet"] .i-muet,
body[data-etat="hors-ligne"] .i-inconnu,
body[data-etat="vps"] .i-inconnu,
body[data-etat="prive"] .i-prive,
body[data-etat="attente"] .i-attente { display: block; }
/* « prive » (appareil non abonné) : carte neutre, comme l'attente ; aucun état du PC */
body[data-etat="prive"] .signe { background: transparent; border: 2px solid var(--bord-fort); color: var(--doux); }

.etat h2 {
  margin: 0;
  color: var(--titre);
  font-size: 1.625rem; font-weight: 750; letter-spacing: -0.02em;
  text-wrap: balance;
}
.etat-phrase {
  margin: var(--e1) 0 0;
  font-size: var(--t-lecture); font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}
.etat-detail {
  margin: var(--e2) 0 0;
  color: var(--doux); font-size: var(--t-aide);
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}
body[data-etat="attente"] .etat-phrase,
body[data-etat="prive"] .etat-phrase { color: var(--doux); font-weight: 400; font-size: var(--t-corps); }

/* « PC muet » : le titre grossit, l'heure aussi */
body[data-etat="muet"] .etat h2 { font-size: 2.125rem; }
body[data-etat="muet"] .etat-phrase { margin-top: 0; font-size: 1.375rem; font-weight: 650; }
body[data-etat="muet"] .etat-detail { color: inherit; font-size: 0.9375rem; }

/* Le délai : une barre du dernier signe de vie (gauche) à l'heure de l'alerte (droite).
   Dessinée en SVG avec des largeurs en pourcentage : aucun style en ligne (comme la jauge de la
   console). Un trait par envoi attendu (toutes les 2 minutes). */
.delai { margin: var(--e4) 0 0; }
.barre { display: block; width: 100%; height: 14px; overflow: visible; }
.barre .piste { fill: var(--piste); }
.barre .plein { fill: var(--disque); }
.barre .repere { stroke: var(--titre); stroke-width: 1; opacity: 0.4; }
.delai-legende {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--e3);
  margin-top: var(--e1);
  color: var(--doux); font-size: var(--t-petit);
  font-variant-numeric: tabular-nums;
}
.delai-legende .fin { margin-left: auto; text-align: right; }
body[data-etat="retard"] .delai-legende .fin,
body[data-etat="prevu"] .delai-legende .fin { color: var(--attention); font-weight: 650; }

/* « Lu sur le VPS à 14:32:05 », sous le bloc */
.lu { margin: 0; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- 6. À faire ---------- */
.quoi > p { margin-bottom: var(--e2); }
.verdict { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; }
.quoi > .aide + .etapes { margin-top: var(--e4); }

/* Étapes numérotées (PC muet, VPS injoignable) : pastille bleue à gauche, filet entre les étapes */
.etapes { list-style: none; margin: 0; padding: 0; counter-reset: etape; }
.etapes > li {
  position: relative;
  counter-increment: etape;
  padding: var(--e3) 0 var(--e3) 40px;
  border-top: 1px solid var(--bord);
}
.etapes > li:last-child { padding-bottom: 0; }
.etapes > li::before {
  content: counter(etape);
  position: absolute; left: 0; top: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-doux); color: var(--accent);
  font-size: var(--t-aide); font-weight: 700;
}
.etapes strong { display: block; font-weight: 650; }
.etapes p { margin: 2px 0 0; font-size: 0.9375rem; }
.etapes p.aide { margin-top: var(--e1); font-size: var(--t-aide); }

/* Le message tout prêt pour la personne sur place : se sélectionne à la main si le partage échoue */
.message-pret {
  margin: var(--e2) 0 0; padding: var(--e3);
  background: var(--creux);
  border-left: 3px solid var(--bord-fort); border-radius: var(--r1);
  font-size: 0.9375rem;
  -webkit-user-select: text; user-select: text;
}

/* ---------- 7. Alertes ---------- */
/* Tant que cet appareil ne reçoit pas les alertes, la carte porte le liseré ambre « à regarder ». */
body[data-abonnement="non"] .alertes,
body[data-abonnement="installer"] .alertes,
body[data-abonnement="refuse"] .alertes { border-color: var(--attention-bord); }

.etat-alertes {
  display: flex; align-items: flex-start; gap: var(--e2);
  margin: 0 0 var(--e2);
  font-weight: 600;
}
.etat-alertes .point { margin-top: 7px; }

/* Code d'invitation (8 chiffres, donné par la console des agents) : champ repris de la console */
.code-invitation { display: block; margin: var(--e3) 0 var(--e2); color: var(--doux); font-size: var(--t-aide); font-weight: 600; }
.code-invitation input {
  display: block; width: 100%; max-width: 12em; min-height: 44px;
  margin-top: var(--e1); padding: 10px var(--e3);
  font: inherit; font-size: 1.25rem; font-weight: 600; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  color: var(--texte); background-color: var(--creux);
  border: 1px solid var(--bord-fort); border-radius: var(--r2);
}
.code-invitation input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }

/* Dernier essai d'alerte : toujours en pied de carte, sous un filet */
.essai {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e2);
  margin: var(--e4) 0 0; padding-top: var(--e3);
  border-top: 1px solid var(--bord);
  font-size: var(--t-aide);
}
.essai .etiquette { flex: 1 1 100%; }
.essai .valeur { font-variant-numeric: tabular-nums; }
.carte > .essai-suite { margin: var(--e2) 0 0; }

/* ---------- 8. Journal ---------- */
.liste {
  list-style: none; margin: 0 0 var(--e4); padding: 0;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r3);
  box-shadow: var(--ombre-1);
  overflow: hidden;
}
.journal li {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: var(--e1) var(--e3);
  padding: var(--e3) var(--e4);
  border-bottom: 1px solid var(--bord);
  font-size: 0.9375rem;
}
.journal li:last-child { border-bottom: 0; }
.journal .quand { color: var(--doux); font-size: var(--t-petit); font-variant-numeric: tabular-nums; white-space: nowrap; }
.journal li.aide { display: block; text-align: center; color: var(--doux); }

/* ---------- 9. Fiche de dépannage (et tout bloc repliable) ---------- */
details.carte { padding: 0 var(--e4); }
details > summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0 var(--e2);
  min-height: 52px; padding: var(--e2) 0;
  list-style: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
details > summary::-webkit-details-marker { display: none; }
.resume-titre { font-weight: 650; }
.resume-detail { color: var(--doux); font-size: var(--t-aide); }
/* Chevron dessiné : vers le bas, replié ; vers le haut, ouvert */
details > summary::after {
  content: ""; flex: none; margin-left: auto;
  width: 9px; height: 9px; margin-right: 4px;
  border-right: 2px solid var(--doux); border-bottom: 2px solid var(--doux);
  transform: translateY(-2px) rotate(45deg);
}
details[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.fiche-dedans { padding: var(--e3) 0 var(--e4); border-top: 1px solid var(--bord); }
.fiche-dedans > :first-child { margin-top: 0; }
.fiche-dedans > :last-child { margin-bottom: 0; }
/* Le bloc produit depuis la fiche imprimée : titres, paragraphes, listes */
#fiche-contenu { font-size: 0.9375rem; }
#fiche-contenu > :last-child { margin-bottom: 0; }
#fiche-contenu ul, #fiche-contenu ol { margin: 0 0 var(--e3); padding-left: 1.4em; }
#fiche-contenu li { margin: var(--e1) 0; }
/* Le lien « Voir la fiche » y mène : la fiche ne doit pas se glisser sous le bandeau */
#fiche { scroll-margin-top: calc(env(safe-area-inset-top) + var(--bandeau-h) + var(--e3)); }

.pied { margin: var(--e5) var(--e1) 0; text-align: center; }

/* ---------- 10. Écran large ---------- */
@media (min-width: 900px) {
  :root { --bandeau-h: 60px; --marge: 24px; }
  main { padding-top: var(--e5); }
}

/* ---------- 11. Mouvement ---------- */
/* Seul mouvement de la page, hors le trait de chargement : les trois points de l'attente. */
.i-attente circle { animation: pouls 1.2s ease-in-out infinite; }
.i-attente circle:nth-child(2) { animation-delay: 0.2s; }
.i-attente circle:nth-child(3) { animation-delay: 0.4s; }
@keyframes pouls {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .i-attente circle { animation: none; }
  .chargement::before { animation: none; width: 100%; opacity: 0.6; }
}
