/* ==========================================================
   MonitoBoard — Design System
   Direction : pupitre de contrôle industriel (HMI)
   ========================================================== */

:root {
  /* Surfaces */
  --bg: #0b0e11;
  --bg-grid: #0d1013;
  --panel: #161b20;
  --panel-raised: #1c2229;
  --bezel: #0a0c0e;
  --line: #2a323a;
  --line-soft: #20262c;

  /* Texte */
  --text: #e8edf1;
  --text-dim: #8b96a1;
  --text-faint: #556069;

  /* Signaux */
  --green: #34d17e;
  --green-dim: #163826;
  --amber: #f2a93b;
  --red: #ef5654;
  --red-dim: #3a1a1a;
  --focus: #5eb1ff;

  /* Forme */
  --radius-panel: 16px;
  --radius-control: 8px;

  /* Typo */
  --font-display: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #12171c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Layout générique plein écran (login / accueil) ---------- */

.stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

/* ---------- Panneau ---------- */

.panel {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 60px -20px rgba(0, 0, 0, 0.6),
    0 0 0 6px var(--bezel);
  padding: 1.75rem 2rem 1.5rem;
}

.panel--narrow { max-width: 380px; }
.panel--control { max-width: 440px; }
.panel--wide { max-width: 720px; }

/* Vis de fixation dans les coins, discret clin d'œil "boîtier" */
.panel::before,
.panel::after {
  content: '';
  position: absolute;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a5560, #1a1f24 70%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.panel::before { left: 12px; }
.panel::after { right: 12px; }

/* ---------- Plaque signalétique (en-tête) ---------- */

.nameplate {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.nameplate h1,
.nameplate h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.nameplate .tag {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.4rem;
}

/* ---------- Voyants (LED encastrées) — élément signature ---------- */

.indicators {
  display: flex;
  justify-content: center;
  gap: 2.75rem;
  padding: 0.75rem 0 1.25rem;
}

.indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.led {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #3c464f 0%, #14181c 72%);
  border: 3px solid #2c343c;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
}

.led::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #171c20;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.led.is-on::after {
  background: var(--green);
  box-shadow: 0 0 16px 4px rgba(52, 209, 126, 0.55), inset 0 0 6px rgba(255, 255, 255, 0.5);
}

/* Voyant "service" : blanc-bleuté, distinct du voyant process (vert) */
.led.service.is-on::after {
  background: #eef4f8;
  box-shadow: 0 0 16px 4px rgba(200, 225, 245, 0.6), inset 0 0 6px rgba(255, 255, 255, 0.7);
}

.led.pulse.is-on::after {
  animation: led-pulse 2.2s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

@media (prefers-reduced-motion: reduce) {
  .led.pulse.is-on::after { animation: none; }
}

.indicator .label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

.indicator .state {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.indicator .state.on { color: var(--green); }
.indicator .state.off { color: var(--text-faint); }

/* ---------- Boutons pupitre ---------- */

.controls {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.controls form { margin: 0; flex: 1; }

.btn-panel {
  width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
}

.btn-panel:active { transform: translateY(1px); }

.btn-start {
  background: linear-gradient(180deg, #2fb374, #1c8a52);
  color: #eafff2;
  box-shadow: 0 2px 0 #145235, 0 6px 14px -6px rgba(47, 179, 116, 0.55);
}
.btn-start:hover:not(:disabled) { filter: brightness(1.08); }

.btn-stop {
  background: linear-gradient(180deg, #e2635f, #b6332f);
  color: #fff1f0;
  box-shadow: 0 2px 0 #7a211f, 0 6px 14px -6px rgba(226, 99, 95, 0.5);
}
.btn-stop:hover:not(:disabled) { filter: brightness(1.08); }

.btn-panel:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: none;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-control);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.btn-link:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Pied de panneau ---------- */

.panel-footer {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.session-info {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.session-info strong { color: var(--text); font-weight: 600; }

.footer-links {
  display: flex;
  gap: 0.6rem;
}

/* ---------- Formulaires ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.field label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field input[type="text"],
.field input[type="password"] {
  background: var(--bezel);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  padding: 0.72rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}
.field input:focus {
  border-color: var(--focus);
}
.field input::placeholder { color: var(--text-faint); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 1.2rem;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, #2fb374, #1c8a52);
  color: #eafff2;
  border: none;
  border-radius: var(--radius-control);
  padding: 0.8rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 2px 0 #145235, 0 6px 14px -6px rgba(47, 179, 116, 0.55);
  transition: filter 0.2s ease;
}
.btn-primary:hover { filter: brightness(1.08); }

.alert {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-control);
  background: var(--red-dim);
  border: 1px solid rgba(239, 86, 84, 0.4);
  color: #ffb3b1;
  font-size: 0.85rem;
  text-align: center;
}

.system-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1.5rem;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.system-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px 1px rgba(52, 209, 126, 0.7);
}

/* ---------- Table (admin) ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.badge.on { color: var(--green); background: var(--green-dim); }
.badge.off { color: var(--text-faint); background: var(--panel-raised); border: 1px solid var(--line); }

.row-actions a {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-faint);
}
.row-actions a:hover { color: var(--focus); border-color: var(--focus); }
.row-actions .sep { color: var(--line); margin: 0 0.4rem; }

.create-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.8rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.create-form .field { margin-bottom: 0; flex: 1 1 160px; }
.create-form .checkbox-row { margin-bottom: 0; }
.create-form .btn-primary { width: auto; padding: 0.72rem 1.4rem; }

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .panel { padding: 1.4rem 1.2rem 1.2rem; }
  .indicators { gap: 1.5rem; }
  .led { width: 48px; height: 48px; }
  .panel-footer { flex-direction: column; align-items: flex-start; }
}
