/* =============================================================================
   UMPS 63 — feuille de style de la console

   Principe directeur : les seules couleurs saturées de l'écran sont celles
   qui portent un état. Le reste de l'interface est en ardoise sourde, pour
   qu'elles se voient d'un bout à l'autre d'une tente de poste de
   commandement, sans rien pour les concurrencer.

   Cette feuille porte l'ossature et le repère de véhicule ; les couleurs de
   statut, elles, sont dans dps.css.

   L'accent bleu est celui de l'étoile de vie du logo de l'association. Il ne
   sert qu'à l'interface (sélection, focus, liens) et jamais à un état.
   ========================================================================== */

:root {
  /* Chrome */
  --nuit:      #131c24;
  --panneau:   #1b2530;
  --relief:    #223040;
  --trait:     #2e3e4c;
  --texte:     #e8eef3;
  --sourdine:  #90a4b5;
  --faible:    #6a7d8d;

  /* Accent d'interface — bleu étoile de vie */
  --vie:       #2e6fd4;
  --vie-clair: #6ba4f0;

  /* États de la liaison — CDC § 6.1. Ne pas réutiliser ailleurs. */
  --ok:        #35cf7f;
  --retard:    #f2a33c;
  --perdu:     #e9484f;
  --jamais:    #6b7c8c;

  --barre-h:   44px;
  --panneau-w: 300px;

  --police:    "Barlow Semi Condensed", "Roboto Condensed", "Segoe UI", system-ui, sans-serif;
  --police-txt:"Barlow", "Segoe UI", system-ui, sans-serif;

  /* Correction appliquée au fond de carte OpenStreetMap. En thème sombre, il
     faut l'assombrir pour qu'il cesse de concurrencer les véhicules ; en thème
     clair, il suffit de le désaturer un peu. */
  --carte-filtre: saturate(.55) brightness(.9) contrast(1.03);
  --carte-fond:   #0e151b;

  /* Fonds des éléments posés SUR la carte : plaques de véhicule, étiquettes
     d'intervention, bandeau de distance. Ils doivent rester lisibles quel que
     soit le fond cartographique, donc changer avec le thème. */
  --flottant:      rgba(19, 28, 36, .92);
  --flottant-doux: rgba(19, 28, 36, .55);
}

/* =============================================================================
   Thème clair
   -------------------------------------------------------------------------
   Pour un poste de commandement en plein jour, sous une tente ouverte ou
   devant une baie vitrée, où l'ardoise sombre devient un miroir.

   Seules les variables changent : aucune règle n'est réécrite. Les couleurs
   d'état sont assombries — les mêmes teintes, posées sur du blanc, perdraient
   le contraste dont elles ont besoin pour se lire à trois mètres.
   ========================================================================== */

:root[data-theme="clair"] {
  --nuit:      #f2f5f8;
  --panneau:   #ffffff;
  --relief:    #e5ebf1;
  --trait:     #cbd6e0;
  --texte:     #17222c;
  --sourdine:  #4e6274;
  --faible:    #6f8496;

  --vie:       #1f5cbf;
  --vie-clair: #17408a;

  --ok:        #128a4d;
  --retard:    #a86200;
  --perdu:     #c22a30;
  --jamais:    #7b8c9b;

  --carte-filtre: saturate(.75);
  --carte-fond:   #e8eef3;

  --flottant:      rgba(255, 255, 255, .94);
  --flottant-doux: rgba(255, 255, 255, .72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--nuit);
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

a { color: var(--vie-clair); }

/* Anneau de focus visible partout : la console peut se piloter au clavier
   quand la souris n'est pas pratique (portable posé sur un coin de table). */
:focus-visible {
  outline: 2px solid var(--vie-clair);
  outline-offset: 2px;
}

/* =============================================================================
   Ossature
   ========================================================================== */

.console {
  display: grid;
  grid-template-rows: var(--barre-h) 1fr;
  grid-template-columns: 1fr var(--panneau-w);
  height: 100%;
}

/* -----------------------------------------------------------------------------
   Barre supérieure
   -------------------------------------------------------------------------- */

.barre {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: var(--panneau);
  border-bottom: 1px solid var(--trait);
  position: relative;
  z-index: 1200;
}

/* Filet d'alerte : apparaît quand la page n'est plus à jour. */
.barre::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--perdu);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease;
}
body.hors-ligne .barre::after { transform: scaleX(1); }

.barre__titre {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: .01em;
  margin: 0;
  white-space: nowrap;
}
.barre__titre span { color: var(--sourdine); font-weight: 500; }

/* L'étoile de vie, en bleu d'interface : elle signe l'écran sans concurrencer
   les couleurs d'état, qui sont les seules à devoir attirer l'œil. */
.barre__signe {
  flex: none;
  color: var(--vie-clair);
}

.barre__espace { flex: 1; }

.barre__nav {
  display: flex;
  gap: 4px;
}

.barre__lien {
  color: var(--sourdine);
  text-decoration: none;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 3px;
  white-space: nowrap;
}
.barre__lien:hover { color: var(--texte); background: var(--relief); }
.barre__lien[aria-current="page"] { color: var(--texte); background: var(--relief); }

/* Battement de cœur : montre que la page est réellement vivante.
   Au poste de commandement, savoir que l'écran se rafraîchit compte autant
   que ce qu'il affiche. */
.pouls {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--faible);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pouls__point {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  opacity: .35;
}
.pouls__point.bat { animation: bat .6s ease-out; }
@keyframes bat {
  0%   { opacity: 1; transform: scale(1.6); }
  100% { opacity: .35; transform: scale(1); }
}
body.hors-ligne .pouls { color: var(--perdu); }
body.hors-ligne .pouls__point { background: var(--perdu); opacity: 1; animation: none; }

/* -----------------------------------------------------------------------------
   Carte
   -------------------------------------------------------------------------- */

#carte {
  grid-row: 2;
  grid-column: 1;
  background: var(--carte-fond);
}

/* Le fond OpenStreetMap est clair et très coloré : forêts vertes, routes
   orange, zones bâties roses. Sans correction, il concurrence les repères des
   véhicules, qui sont pourtant la seule chose à regarder. On le désature et on
   l'assombrit juste assez pour qu'il redevienne un fond. */
.leaflet-tile-pane { filter: var(--carte-filtre); }

.leaflet-container {
  background: var(--carte-fond);
  font-family: var(--police);
}

.leaflet-control-attribution {
  background: var(--flottant) !important;
  color: var(--faible) !important;
  font-family: var(--police-txt);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--sourdine) !important; }

.leaflet-bar a {
  background: var(--panneau) !important;
  color: var(--texte) !important;
  border-color: var(--trait) !important;
}
.leaflet-bar a:hover { background: var(--relief) !important; }

/* =============================================================================
   Le repère de véhicule
   -------------------------------------------------------------------------
   C'est l'élément sur lequel tout l'écran est construit. Il porte trois
   informations simultanées :
     — la direction, par l'orientation du chevron ;
     — l'état de la liaison, par la couleur ;
     — la CONFIANCE dans la position, par l'anneau, qui se délite à mesure
       que le point vieillit : plein, puis tirets, puis pointillés.
   L'anneau permet de juger la fraîcheur d'une position sans consulter la
   légende ni lire un chiffre.
   ========================================================================== */

.mk {
  position: relative;
  width: 34px;
  height: 34px;
}

.mk__anneau {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--etat, var(--jamais));
  background: var(--flottant-doux);
}

/* Le délitement de l'anneau */
.mk--online .mk__anneau { border-style: solid; }
.mk--late   .mk__anneau { border-style: dashed; }
.mk--lost   .mk__anneau { border-style: dotted; opacity: .8; }
.mk--never  .mk__anneau { border-style: dotted; opacity: .45; border-width: 1px; }

/* Chevron orienté au cap, pour un véhicule en mouvement */
.mk__cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 18px;
  margin: -9px 0 0 -8px;
  background: var(--etat, var(--jamais));
  clip-path: polygon(50% 0%, 100% 100%, 50% 78%, 0% 100%);
  transform: rotate(var(--cap, 0deg));
  transform-origin: 50% 50%;
  transition: transform .4s ease;
}

/* Disque, pour un véhicule à l'arrêt : la forme dit « immobile » avant que la
   couleur ne dise « en ligne ». */
.mk--arret .mk__cap {
  width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px;
  clip-path: circle(50%);
  transform: none;
}

/* Plaque de nom, accrochée au repère. Toujours visible : le CDC § 6.1 exige
   le nom du véhicule affiché en permanence à côté du repère. */
.mk__plaque {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 7px 2px 6px;
  background: var(--flottant);
  border-left: 5px solid var(--etat, var(--jamais));
  border-radius: 0 3px 3px 0;
  color: var(--texte);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  letter-spacing: .01em;
}

.mk--suivi .mk__anneau {
  box-shadow: 0 0 0 3px rgba(46, 111, 212, .55);
}

/* =============================================================================
   Panneau latéral
   -------------------------------------------------------------------------
   L'ossature seule. Le contenu — véhicules, interventions, main courante — est
   habillé par dps.css, qui porte les couleurs de statut.
   ========================================================================== */

.panneau {
  grid-row: 2;
  grid-column: 2;
  background: var(--panneau);
  border-left: 1px solid var(--trait);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: opacity .25s ease;
}
body.hors-ligne .panneau { opacity: .5; }

.panneau__entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 11px 14px 9px;
  border-bottom: 1px solid var(--trait);
}
.panneau__entete h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--sourdine);
  letter-spacing: .04em;
}
.panneau__compte {
  font-size: 13px;
  color: var(--faible);
  font-variant-numeric: tabular-nums;
}

/* Écran vide : une invitation à agir, pas un message d'excuse. */
.vide {
  padding: 22px 16px;
  color: var(--sourdine);
  font-family: var(--police-txt);
  font-size: 14px;
  line-height: 1.6;
}
.vide strong { color: var(--texte); display: block; margin-bottom: 5px; font-weight: 600; }

/* =============================================================================
   Formulaires et pages secondaires
   ========================================================================== */

.champ {
  display: block;
  margin-bottom: 14px;
}
.champ > span {
  display: block;
  font-size: 13px;
  color: var(--sourdine);
  margin-bottom: 4px;
}

input[type="text"], input[type="password"], input[type="datetime-local"],
input[type="number"], select {
  width: 100%;
  padding: 8px 10px;
  background: var(--nuit);
  border: 1px solid var(--trait);
  border-radius: 3px;
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
}
input:focus, select:focus { border-color: var(--vie); }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--vie);
  color: #fff;
  border: 1px solid var(--vie);
  border-radius: 3px;
  font-family: var(--police);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.bouton:hover { background: var(--vie-clair); border-color: var(--vie-clair); }

.bouton--sobre {
  background: transparent;
  color: var(--texte);
  border-color: var(--trait);
}
.bouton--sobre:hover { background: var(--relief); border-color: var(--sourdine); }

.bouton--danger { background: transparent; color: var(--perdu); border-color: var(--perdu); }
.bouton--danger:hover { background: var(--perdu); color: #fff; }

/* Bouton réduit à son icône, pour les actions de bout de ligne.
   Le libellé reste dans title= et dans un texte lu par les lecteurs d'écran :
   une icône seule n'est jamais une étiquette suffisante. */
.bouton-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  color: var(--sourdine);
  border: 1px solid var(--trait);
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}
.bouton-icone:hover { background: var(--relief); border-color: var(--sourdine); color: var(--texte); }
.bouton-icone--danger:hover { background: var(--perdu); border-color: var(--perdu); color: #fff; }

/* Les deux boutons d'action tenus ensemble, à droite de la ligne. */
.actions-ligne { display: flex; gap: 6px; justify-content: flex-end; }
.actions-ligne form { display: inline; }

/* Texte réservé aux lecteurs d'écran : hors de l'image, jamais hors de l'arbre
   d'accessibilité (display:none l'en sortirait). */
.pour-lecteur {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Message d'erreur : dit ce qui s'est passé et comment le corriger. */
.alerte {
  padding: 10px 12px;
  border-left: 3px solid var(--perdu);
  background: rgba(233, 72, 79, .12);
  font-family: var(--police-txt);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.alerte--ok { border-left-color: var(--ok); background: rgba(53, 207, 127, .1); }
.alerte--info { border-left-color: var(--vie); background: rgba(46, 111, 212, .12); }

/* -----------------------------------------------------------------------------
   Page de connexion
   -------------------------------------------------------------------------- */

body.page-connexion {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
}

.connexion {
  width: 100%;
  max-width: 340px;
}
.connexion__marque {
  margin-bottom: 26px;
}
.connexion__signe {
  display: block;
  color: var(--vie-clair);
  margin-bottom: 14px;
}
.connexion__marque h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: .01em;
}
.connexion__marque p {
  margin: 0;
  color: var(--sourdine);
  font-family: var(--police-txt);
  font-size: 14px;
}
.connexion .bouton { width: 100%; margin-top: 4px; }
.connexion__pied {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--trait);
  color: var(--faible);
  font-family: var(--police-txt);
  font-size: 12.5px;
  line-height: 1.6;
}

/* -----------------------------------------------------------------------------
   Pages en pleine largeur (historique, administration)
   -------------------------------------------------------------------------- */

body.page-large { overflow: auto; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}
.page h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px;
}
.page h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 34px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--trait);
}
.page p {
  font-family: var(--police-txt);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--sourdine);
  max-width: 68ch;
}

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tableau th {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--sourdine);
  padding: 8px 10px;
  border-bottom: 1px solid var(--trait);
  white-space: nowrap;
}
.tableau td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(46, 62, 76, .5);
  vertical-align: middle;
}
.tableau tr:hover td { background: rgba(34, 48, 64, .5); }
.tableau .num { font-variant-numeric: tabular-nums; text-align: right; }
.tableau code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  color: var(--vie-clair);
}

.barre-outils {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  background: var(--panneau);
  border: 1px solid var(--trait);
  border-radius: 3px;
  margin-bottom: 18px;
}
.barre-outils .champ { margin: 0; }
.barre-outils .champ--large { flex: 1; min-width: 180px; }

.fiche {
  background: var(--panneau);
  border: 1px solid var(--trait);
  border-radius: 3px;
  padding: 16px;
  margin-bottom: 18px;
}

.chiffres {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin: 0 0 18px;
}
/* Sans cette ligne, « display: flex » l'emporte sur l'attribut hidden et le
   bloc reste affiché, vide, quand aucun trajet n'est chargé. */
.chiffres[hidden] { display: none; }
.chiffres div span {
  display: block;
  font-size: 12px;
  color: var(--faible);
  letter-spacing: .03em;
}
.chiffres div strong {
  font-size: 25px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#carte-historique {
  height: 460px;
  border: 1px solid var(--trait);
  border-radius: 3px;
}

.etat-inactif { color: var(--faible); }
.etat-actif   { color: var(--ok); }

/* =============================================================================
   Écrans étroits — téléphone au bord du terrain (CDC § 6.3, scénario 2)
   ========================================================================== */

@media (max-width: 900px) {
  .console {
    grid-template-columns: 1fr;
    grid-template-rows: var(--barre-h) 1fr 42vh;
  }
  #carte   { grid-column: 1; grid-row: 2; }
  .panneau {
    grid-column: 1;
    grid-row: 3;
    border-left: none;
    border-top: 1px solid var(--trait);
  }
  .barre__titre span { display: none; }
}

@media (max-width: 560px) {
  .barre { gap: 10px; padding: 0 10px; }
  .pouls span { display: none; }
}

/* Mouvement réduit : on garde l'information, on retire l'animation. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
