/* Tableau de bord FeelPrint — servi par le serveur relais.
 *
 * Deux exigences, jamais l'une contre l'autre : lisible au lecteur d'écran
 * (la structure est dans le HTML) et agréable à l'œil. Ici : jetons de
 * couleur en clair et en sombre, contrastes ≥ 4,5:1 pour tout texte, focus
 * toujours visible, aucune information portée par la couleur seule (chaque
 * pastille a une icône et un mot), respect de prefers-reduced-motion et de
 * forced-colors.
 */

:root {
  color-scheme: light dark;
  --fond: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --bord: #d3d9e2;
  --texte: #1a1f26;
  --texte-2: #4d5766;
  --accent: #1d5fc2;
  --accent-texte: #ffffff;
  --accent-piste: #d4e1f7;
  --bon: #0c6b34;
  --bon-fond: #dcf3e4;
  --attention: #8a5a00;
  --attention-fond: #fdeccb;
  --critique: #b3261e;
  --critique-fond: #fadcda;
  --neutre: #5b6675;
  --neutre-fond: #e7ebf0;
  --ombre: 0 1px 2px rgba(20, 30, 50, .06), 0 6px 18px rgba(20, 30, 50, .06);
  --rayon: 14px;
  --focus: #ffb300;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1318;
    --surface: #171c23;
    --surface-2: #202731;
    --bord: #2c3542;
    --texte: #e9edf2;
    --texte-2: #a9b3c0;
    --accent: #8db6ff;
    --accent-texte: #0b1a33;
    --accent-piste: #263a5c;
    --bon: #7fd8a1;
    --bon-fond: #163524;
    --attention: #f5c56b;
    --attention-fond: #3d2c0a;
    --critique: #ff9a93;
    --critique-fond: #4a1d1a;
    --neutre: #b4bdc9;
    --neutre-fond: #2a323d;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --focus: #ffd166;
  }
}

* { box-sizing: border-box; }

/* L'attribut `hidden` doit gagner sur toute règle d'affichage, y compris
 * `display: grid` d'un identifiant : sans ce renfort, la vue cachée
 * réapparaît et le lecteur d'écran lit deux écrans à la fois. */
[hidden] { display: none !important; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Focus : un anneau épais, à fort contraste, sur tout ce qui en reçoit. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.lien-evitement {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: .6rem 1rem;
  background: var(--accent);
  color: var(--accent-texte);
  border-radius: 8px;
  z-index: 10;
  text-decoration: none;
  font-weight: 600;
}
.lien-evitement:focus { top: 1rem; }

/* -- En-tête ------------------------------------------------------------- */

.entete {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem .5rem;
}
.marque {
  margin: 0;
  font-size: .85rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--texte-2);
  font-weight: 600;
}
h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw + 1rem, 2.1rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}

.entete-liens { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.entete-liens a { color: var(--accent); font-weight: 600; text-decoration: none; }
.entete-liens a:hover { text-decoration: underline; }

.etats-liaison {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

/* Pastille : icône + mot, couleur en renfort seulement. */
.pastille {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  background: var(--neutre-fond);
  color: var(--neutre);
  border: 1px solid transparent;
}
.pastille-icone { font-size: .8em; }
.pastille[data-etat="bon"] { background: var(--bon-fond); color: var(--bon); }
.pastille[data-etat="attention"] { background: var(--attention-fond); color: var(--attention); }
.pastille[data-etat="critique"] { background: var(--critique-fond); color: var(--critique); }

/* -- Contenu ------------------------------------------------------------- */

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: .5rem 1.25rem 2rem;
  display: grid;
  gap: 1rem;
}
main:focus { outline: none; }
#vue-tableau { display: grid; gap: 1rem; }

.carte {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1.25rem 1.5rem;
}
.carte h2 {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--texte-2);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.carte h3 {
  margin: 1.1rem 0 .5rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--texte);
}
.carte h3:first-child { margin-top: 0; }
.compteur {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .45em;
  margin-left: .35em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--texte);
  font-size: .8rem;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
}
.compteur:empty { display: none; }

.aide { color: var(--texte-2); font-size: .95rem; margin: .25rem 0 0; }
.vide { color: var(--texte-2); margin: 0; }
.erreur { color: var(--critique); font-weight: 600; margin: .5rem 0; }

/* -- Formulaire ---------------------------------------------------------- */

.carte-connexion { max-width: 34rem; }
.carte-connexion h2 { text-transform: none; font-size: 1.4rem; color: var(--texte); letter-spacing: 0; }
.champ { margin: 1rem 0; }
.champ label { display: block; font-weight: 600; margin-bottom: .35rem; }
.champ input[type="text"], .champ input[type="password"] {
  width: 100%;
  font: inherit;
  padding: .65rem .8rem;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--surface);
  color: var(--texte);
}
.champ-case { display: flex; align-items: center; gap: .6rem; }
.champ-case label { margin: 0; font-weight: 500; }
.champ-case input { width: 1.15rem; height: 1.15rem; }

.champ-televerser {
  padding: .9rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--surface-2);
}
.champ-televerser input[type="file"] { display: block; width: 100%; margin: .4rem 0; color: var(--texte); }
.champ-televerser .bouton { margin-top: .5rem; }

.bouton {
  font: inherit;
  font-weight: 600;
  padding: .6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--bord);
  background: var(--surface-2);
  color: var(--texte);
  cursor: pointer;
}
.bouton:hover { filter: brightness(.96); }
.bouton-principal { background: var(--accent); color: var(--accent-texte); border-color: transparent; }
.bouton-discret { background: transparent; }
.bouton-danger { color: var(--critique); border-color: var(--critique); }
.bouton[disabled] { opacity: .55; cursor: default; }

.barre-outils { display: flex; flex-wrap: wrap; gap: .6rem; }

/* -- Réglages, fichiers (ajoutés le 14 septembre 2026) -------------------- */

.ligne-reglage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .6rem 0;
}
.champ-radio { border: none; margin: .5rem 0; padding: 0; }
.champ-radio legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.champ-radio label { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: .3rem 0; }

.ligne-temperature {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .5rem 0;
}
.ligne-temperature label { font-weight: 600; min-width: 11rem; }
.ligne-temperature input[type="range"] { flex: 1 1 10rem; }
.ligne-temperature output { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.liste-fichiers { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .5rem; }
.ligne-fichier {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .6rem .9rem;
  border-radius: 10px;
  background: var(--surface-2);
}
.ligne-fichier .fichier-nom { font-weight: 600; overflow-wrap: anywhere; }
.ligne-fichier .fichier-taille { color: var(--texte-2); font-size: .9rem; }

.dernier-etat {
  margin: 0;
  padding: .7rem 1rem;
  border-radius: 10px;
  background: var(--attention-fond);
  color: var(--attention);
  font-weight: 600;
}

/* -- Impression ---------------------------------------------------------- */

.etat-job {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.fichier { margin: .15rem 0 1rem; color: var(--texte-2); overflow-wrap: anywhere; }
.fichier:empty { display: none; }

.progression { display: grid; gap: .9rem; }
.chiffre-hero {
  font-size: clamp(2.8rem, 6vw, 3.6rem);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.02em;
}
.chiffre-hero .unite { font-size: .45em; font-weight: 500; color: var(--texte-2); }

.barre {
  height: 14px;
  border-radius: 999px;
  background: var(--accent-piste);
  overflow: hidden;
}
.barre-remplissage {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .6s ease;
}
.barre[data-etat="pause"] .barre-remplissage { background: var(--attention); }
.barre[data-etat="echec"] .barre-remplissage { background: var(--critique); }
.barre[data-etat="termine"] .barre-remplissage { background: var(--bon); }

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .75rem 1.25rem;
  margin: 0;
}
.details div { display: grid; gap: .1rem; }
.details dt { font-size: .82rem; color: var(--texte-2); text-transform: uppercase; letter-spacing: .06em; }
.details dd { margin: 0; font-weight: 600; font-size: 1.05rem; }

/* -- Températures : tuiles ----------------------------------------------- */

.tuiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: .9rem;
}
.tuile {
  padding: .9rem 1rem;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  gap: .35rem;
}
.tuile-libelle { font-weight: 600; color: var(--texte-2); }
.tuile-valeur { font-size: 1.9rem; font-weight: 650; line-height: 1.1; }
.tuile-valeur small { font-size: .55em; font-weight: 500; color: var(--texte-2); }
.tuile-etat { font-size: .9rem; color: var(--texte-2); }
.tuile .barre { height: 8px; }

/* -- Caméra : une photo, pas une vidéo ------------------------------------ */

.camera { margin: .9rem 0 0; display: grid; gap: .5rem; }
.camera-cadre {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.camera-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Photo ancienne ou caméra en pause : assombrie, et la légende le dit aussi. */
.camera[data-etat="perime"] .camera-image,
.camera[data-etat="pause"] .camera-image { filter: grayscale(.6) brightness(.8); }
.camera-attente { margin: 0; padding: 1rem; color: var(--texte-2); text-align: center; }
.camera figcaption { color: var(--texte-2); font-size: .95rem; font-variant-numeric: tabular-nums; }
.camera[data-etat="perime"] figcaption { color: var(--attention); font-weight: 600; }

/* -- Alertes ------------------------------------------------------------- */

.liste-alertes { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.liste-alertes:empty + .vide { display: block; }
.liste-alertes:not(:empty) + .vide { display: none; }
.alerte {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .7rem .9rem;
  border-radius: 10px;
  border: 1px solid var(--bord);
  border-left-width: 5px;
}
.alerte[data-gravite="info"] { border-left-color: var(--neutre); }
.alerte[data-gravite="important"] { border-left-color: var(--attention); }
.alerte[data-gravite="critique"] { border-left-color: var(--critique); background: var(--critique-fond); }
.alerte .pastille { flex: none; }
.alerte-code { display: block; font-size: .85rem; color: var(--texte-2); font-family: ui-monospace, Consolas, monospace; }

/* -- AMS ------------------------------------------------------------------ */

.liste-slots { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.slot { display: flex; align-items: center; gap: .75rem; }
.slot-couleur {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 2px solid var(--bord);
  background: var(--surface-2);
}
.slot[data-actif="oui"] { font-weight: 600; }

/* -- Journal -------------------------------------------------------------- */

.journal { margin: .5rem 0 0; padding-left: 1.5rem; color: var(--texte-2); font-size: .95rem; }
.journal li { margin: .2rem 0; }
.journal time { font-variant-numeric: tabular-nums; color: var(--texte); margin-right: .5rem; }

/* -- Pied : régions vivantes --------------------------------------------- */

.pied {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}
.annonce {
  margin: 0;
  min-height: 1.5rem;
  color: var(--texte-2);
  font-size: .95rem;
}
.annonce:not(:empty)::before { content: "Dernière annonce : "; font-weight: 600; }
.annonce-urgente { color: var(--critique); font-weight: 600; }
.annonce-urgente:not(:empty)::before { content: "Alerte : "; }
.copyright { margin: .5rem 0 0; color: var(--texte-2); font-size: .85rem; }
.pied-liens { margin: .25rem 0 0; color: var(--texte-2); font-size: .85rem; }
.pied-liens a { color: var(--accent); }

/* -- Préférences système ------------------------------------------------- */

/* -- Confirmation (pause/reprise ne demandent rien, arrêt et lancement si) - */

dialog#dialogue-confirmation {
  max-width: 28rem;
  width: calc(100% - 2rem);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  background: var(--surface);
  color: var(--texte);
  padding: 1.5rem;
}
dialog#dialogue-confirmation::backdrop { background: rgba(10, 14, 20, .55); }
dialog#dialogue-confirmation h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
dialog#dialogue-confirmation p { margin: 0 0 1.25rem; }
dialog#dialogue-confirmation form { margin: 0; }
dialog#dialogue-confirmation .barre-outils { justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .barre-remplissage { transition: none; }
}

@media (forced-colors: active) {
  .pastille, .alerte, .tuile, .carte, .camera-cadre { border: 1px solid CanvasText; }
  .barre { border: 1px solid CanvasText; }
  .barre-remplissage { background: Highlight; }
  .slot-couleur { forced-color-adjust: none; }
}

@media (max-width: 40rem) {
  .carte { padding: 1rem 1.1rem; }
  .entete { padding-top: 1rem; }
}
