/* Design system Mission Control — base (lot 2a).
 * Direction validée Q2 : HUD sombre, verre dépoli, cyan/orange.
 * Le CSS HUD spécifique (canvas, toasts, gauges...) arrive au lot 2b. */
:root {
  color-scheme: dark;
  --fond-0: #070b16;
  --fond-1: #0b1220;
  --fond-2: #111a2e;
  --verre: rgb(17 26 46 / 72%);
  --bordure: rgb(53 224 255 / 22%);
  --texte: #e6edf3;
  --texte-doux: #9fb0c3;
  --cyan: #35e0ff;
  --orange: #ff9a3c;
  --vert: #3fb950;
  --bleu: #58a6ff;
  --rouge: #ff7b72;
  --police-texte: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --police-chiffres: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --rayon: 10px;
  --transition: 150ms ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(1200px 800px at 80% -10%, #12203c 0%, transparent 60%),
    radial-gradient(900px 700px at 10% 110%, #0e2a3a 0%, transparent 55%),
    var(--fond-0);
  color: var(--texte);
  font-family: var(--police-texte);
  margin: 0;
  min-height: 100vh;
}

/* Coquille : barre latérale + contenu. */
main {
  max-width: none;
  margin: 0;
  padding: 0;
}

.coquille {
  display: grid;
  grid-template-columns: 13rem 1fr;
  min-height: 100vh;
}

.barre-laterale {
  background: var(--verre);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--bordure);
  padding: 1rem;
}

.barre-laterale nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.barre-laterale a {
  border-radius: 6px;
  color: var(--texte-doux);
  padding: 0.45rem 0.6rem;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.barre-laterale a:hover {
  background: rgb(53 224 255 / 10%);
  color: var(--texte);
}

.barre-laterale a.actif {
  background: rgb(53 224 255 / 16%);
  color: var(--cyan);
}

.contenu {
  padding: 1.5rem 2rem 4rem;
  max-width: 80rem;
}

/* Panneaux verre dépoli. */
.panneau {
  background: var(--verre);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.panneau h2 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-doux);
  margin: 0 0 0.75rem;
}

/* Chiffres : fonte technique, cliquables vers leur source. */
.chiffre {
  font-family: var(--police-chiffres);
  font-size: 1.6rem;
  color: var(--texte);
}

a.chiffre {
  color: var(--cyan);
  text-decoration: none;
}

a.chiffre:hover {
  text-decoration: underline;
}

/* Formulaires : labels + champs sombres + boutons. */
form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 28rem;
}

label {
  color: var(--texte-doux);
  font-size: 0.85rem;
}

input,
select,
textarea {
  background: var(--fond-2);
  border: 1px solid var(--bordure);
  border-radius: 6px;
  color: var(--texte);
  font: inherit;
  padding: 0.5rem 0.65rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button {
  align-self: flex-start;
  background: rgb(53 224 255 / 14%);
  border: 1px solid var(--bordure);
  border-radius: 6px;
  color: var(--cyan);
  cursor: pointer;
  font: inherit;
  padding: 0.5rem 1rem;
  transition: background var(--transition);
}

button:hover {
  background: rgb(53 224 255 / 24%);
}

button.danger {
  background: rgb(255 123 114 / 12%);
  border-color: rgb(255 123 114 / 40%);
  color: var(--rouge);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.error {
  color: var(--rouge);
}

body:has(> main.login) {
  display: grid;
  min-height: 100vh;
  padding: 1.5rem;
  place-items: center;
}

main.login {
  background: var(--verre);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: 0 0 40px rgb(53 224 255 / 8%);
  max-width: 24rem;
  padding: 2rem 1.75rem;
  width: 100%;
}

main.login h1 {
  font-size: 1.25rem;
  margin: 0 0 0.45rem;
  text-align: center;
}

main.login > p {
  color: var(--texte-doux);
  margin: 0 0 1.25rem;
  text-align: center;
}

main.login form {
  max-width: none;
  width: 100%;
}

main.login button {
  align-self: stretch;
}

.cliquable {
  cursor: pointer;
}

.cliquable:hover {
  color: var(--cyan);
}

/* Badges d'état (texte + pastille). */
.badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
}

.badge-vert {
  background: rgb(63 185 80 / 16%);
  color: var(--vert);
}

.badge-orange {
  background: rgb(255 154 60 / 16%);
  color: var(--orange);
}

.badge-rouge {
  background: rgb(255 123 114 / 16%);
  color: var(--rouge);
}

.badge-bleu {
  background: rgb(88 166 255 / 16%);
  color: var(--bleu);
}

/* Squelettes de chargement (jamais de page blanche). */
.squelette {
  animation: pulsation 1.2s ease-in-out infinite;
  background: rgb(159 176 195 / 14%);
  border-radius: 6px;
  min-height: 1rem;
}

@keyframes pulsation {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

/* Accessibilité : respecte la réduction de mouvement. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- HUD lot 2b : toasts, drawer, modale, jauges, canvas, tableaux. --- */

.toasts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 50;
  max-width: 22rem;
}

.toast {
  background: var(--verre);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 0.65rem 0.9rem;
}

.toast-succes {
  border-color: rgb(63 185 80 / 45%);
}

.toast-erreur {
  border-color: rgb(255 123 114 / 45%);
}

.drawer {
  background: var(--verre);
  backdrop-filter: blur(14px);
  border-left: 1px solid var(--bordure);
  bottom: 0;
  overflow-y: auto;
  padding: 1.25rem;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(105%);
  transition: transform 200ms ease-out;
  width: min(32rem, 92vw);
  z-index: 40;
}

.drawer.ouvert {
  transform: none;
}

.fond-modale {
  align-items: center;
  background: rgb(7 11 22 / 70%);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 60;
}

.fond-modale[hidden] {
  display: none;
}

.modale {
  background: var(--fond-1);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  max-width: 28rem;
  padding: 1.25rem 1.5rem;
  width: calc(100vw - 2rem);
}

.modale .actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.jauge {
  background: rgb(159 176 195 / 14%);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
}

.jauge > span {
  background: var(--cyan);
  display: block;
  height: 100%;
  transition: width 200ms ease-out;
}

.jauge.alerte > span {
  background: var(--orange);
}

.jauge.danger > span {
  background: var(--rouge);
}

.hud-canvas {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  display: block;
  width: 100%;
  height: auto;
}

.hero[data-etat='urgent'] {
  border: 1px solid var(--orange);
}

.hero[data-etat='erreur'] {
  border: 1px solid var(--rouge);
}

.hero-layout {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.hero-layout .hud-canvas {
  flex: 0 0 auto;
  width: 120px;
}

.sparkline {
  display: block;
}

.system-layout {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
}

.system-layout .hud-canvas {
  flex: 1 1 auto;
  min-width: 0;
}

.panneau-ilot {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  flex: 0 0 220px;
  padding: 0.75rem;
}

.panneau-ilot h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

[data-ilot='sante'] {
  font-weight: bold;
}

[data-ilot='sante'][data-niveau='ok'] {
  color: var(--vert);
}

[data-ilot='sante'][data-niveau='degrade'] {
  color: var(--orange);
}

[data-ilot='sante'][data-niveau='erreur'] {
  color: var(--rouge);
}

[data-ilot='sante'][data-niveau='inconnu'] {
  color: var(--texte-doux);
}

.ilots-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
}

.ilot-btn {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}

.ilot-btn.actif {
  border-color: var(--cyan);
}

.panneau h3 {
  font-size: 0.95rem;
  margin: 0.75rem 0 0.25rem;
}

.matrice {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}

.matrice th,
.matrice td {
  border-bottom: 1px solid var(--bordure);
  padding: 0.3rem 0.5rem;
  text-align: left;
}

.matrice td.alerte {
  color: var(--rouge);
  font-weight: bold;
}

.lien-point {
  background: none;
  border: none;
  color: var(--cyan);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.modale label {
  display: block;
  margin: 0.5rem 0;
}

.modale input {
  margin-left: 0.5rem;
}

.tickets-filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.lien-ticket {
  background: none;
  border: none;
  color: var(--texte);
  cursor: pointer;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.carte-actes {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.memory-nav {
  align-items: center;
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

kbd {
  background: var(--fond-2);
  border: 1px solid var(--bordure);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--police-chiffres);
  font-size: 0.8em;
  padding: 0.1rem 0.4rem;
}

table.tableau {
  border-collapse: collapse;
  width: 100%;
}

table.tableau th,
table.tableau td {
  border-bottom: 1px solid rgb(159 176 195 / 16%);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

table.tableau th {
  color: var(--texte-doux);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.diff-bloc {
  background: var(--fond-0);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  font-family: var(--police-chiffres);
  font-size: 0.85rem;
  overflow-x: auto;
  padding: 0.75rem;
  white-space: pre-wrap;
}

.journal-serveur {
  max-height: 28rem;
  overflow-y: auto;
}

.cmdk-fond {
  align-items: flex-start;
  padding-top: 10vh;
}

.cmdk-boite {
  background: var(--fond-1);
  border: 1px solid var(--cyan);
  border-radius: var(--rayon);
  box-shadow: 0 10px 30px rgb(0 0 0 / 70%), 0 0 20px rgb(53 224 255 / 20%);
  display: flex;
  flex-direction: column;
  max-width: 560px;
  overflow: hidden;
  width: 100%;
}

.cmdk-input {
  background: var(--fond-2);
  border: none;
  border-bottom: 1px solid var(--bordure);
  color: var(--texte);
  font-family: var(--police-texte);
  font-size: 1rem;
  outline: none;
  padding: 0.85rem 1rem;
  width: 100%;
}

.cmdk-liste {
  list-style: none;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.cmdk-item {
  color: var(--texte);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  transition: background 0.15s ease;
}

.cmdk-item:hover,
.cmdk-item.selectionne {
  background: rgb(53 224 255 / 15%);
  color: var(--cyan);
}

.cmdk-vide {
  color: var(--texte-doux);
  padding: 0.8rem 1rem;
  text-align: center;
}

.cmdk-hint {
  margin-left: auto;
}

/* Animations et transitions globales */
button,
a,
input,
select {
  transition: all var(--transition);
}

.panneau {
  transition: border-color var(--transition), box-shadow var(--transition);
}

.panneau:hover {
  border-color: rgb(53 224 255 / 35%);
}

/* Responsive mobile-first adjustments */
@media (max-width: 768px) {
  .coquille {
    grid-template-columns: 1fr;
  }

  .barre-laterale {
    border-bottom: 1px solid var(--bordure);
    border-right: none;
    overflow-x: auto;
    padding: 0.5rem;
  }

  .barre-laterale nav {
    flex-direction: row;
    gap: 0.5rem;
  }

  .contenu {
    padding: 1rem 0.75rem 3rem;
  }

  .system-layout {
    flex-direction: column;
  }

  .panneau-ilot {
    flex: 1 1 auto;
    width: 100%;
  }

  .cmdk-boite {
    margin: 0 1rem;
    max-width: 100%;
  }
}
