/* ============================================================================
 * dashboard.css — SAFRAN cold-room HMI dashboard
 * Look & feel aligned with the Honeywell MX60 "cockpit" pattern:
 * deep navy base, teal accent, Inter + JetBrains Mono, 2px state stripes,
 * glowing mono numbers, pulsing LEDs, spring hover. 3D always centered.
 * ========================================================================== */

:root {
  /* backgrounds */
  --bg:            #06080d;
  --bg-elevated:   #0c1018;
  --surface:       rgba(17, 24, 39, 0.60);
  --surface-solid: #111827;
  --surface-dim:   rgba(17, 24, 39, 0.40);

  /* borders */
  --border:       rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.03);
  --border-hover: rgba(0, 212, 170, 0.30);

  /* accent: Honeywell teal */
  --accent:       #00d4aa;
  --accent-light: #00e8bc;
  --accent-glow:  rgba(0, 212, 170, 0.15);

  /* state semaphore */
  --on:      #00e676;
  --off:     #ff4455;
  --alarm:   #fbbf24;
  --offline: #475569;

  /* text */
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  /* type */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* shape */
  --radius:    10px;
  --radius-lg: 12px;
  --spring:    cubic-bezier(0.34, 1.4, 0.64, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 14px; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 700px at 50% -10%, #0b1622 0%, transparent 60%),
    var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 26px;
  background: rgba(8, 11, 18, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}
.brand { display: flex; flex-direction: column; line-height: 1.25; }
.brand .name { color: #f8fafc; font-weight: 700; font-size: 15px; letter-spacing: 0.18em; }
.brand .sub  { color: var(--text-muted); font-size: 9px; letter-spacing: 0.24em; }
.brand .accent { color: var(--accent); }
.top .spacer { flex: 1; }

.clock { font-family: var(--font-mono); font-size: 14px; color: var(--text-secondary); letter-spacing: 0.06em; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; color: var(--on); text-transform: uppercase;
}
.status-pill.is-alarm { color: var(--alarm); border-color: rgba(251,191,36,0.4); }
.status-pill.is-offline { color: var(--offline); border-color: rgba(71,85,105,0.5); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor;
       box-shadow: 0 0 10px currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ================================================================= cockpit */
.cockpit {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(460px, calc(100vh - 230px));
  grid-template-areas:
    "metrics metrics metrics"
    "left    center  right";
  gap: 12px;
  padding: 14px;
}
.cockpit__metrics { grid-area: metrics; display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.cockpit__left   { grid-area: left;   display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.cockpit__center { grid-area: center; position: relative; }
.cockpit__right  { grid-area: right;  display: flex; flex-direction: column; gap: 12px; min-height: 0; }

/* ---- KPI cards (top row) ---- */
.kpi {
  position: relative; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(12,16,26,0.78) 0%, rgba(8,11,18,0.62) 100%),
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--kpi-color, transparent) 0%, transparent 70%);
  background-blend-mode: normal, screen;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 11px 11px;
  transition: transform 0.22s var(--spring), border-color 0.22s ease;
}
.kpi::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--kpi-color, var(--accent)); opacity: 0.9;
  box-shadow: 0 0 12px var(--kpi-color, var(--accent));
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-hover); }
.kpi-label { font-size: 8px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(255,255,255,0.40); }
.kpi-io { float: right; font-size: 7.5px; color: var(--kpi-color, var(--accent)); opacity: 0.7; letter-spacing: 0.1em; }
.kpi-value {
  font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-top: 6px;
  color: var(--kpi-color, var(--text-primary)); line-height: 1;
  text-shadow: 0 0 12px color-mix(in srgb, var(--kpi-color, var(--accent)) 35%, transparent);
}
.kpi-value small { font-size: 10px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }

/* ---- side panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  display: flex; flex-direction: column; min-height: 0;
}
.panel-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 10px; padding-bottom: 9px;
  border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between;
}
.panel-title span { color: var(--accent); opacity: 0.8; }
.panel-scroll { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 7px; }

/* identity block */
.ident .ident-row { display: flex; justify-content: space-between; align-items: center; margin: 5px 0; }
.ident .ident-row .l { font-size: 10px; color: var(--text-muted); letter-spacing: 0.08em; }
.ident .ident-row .v { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.ident .big { font-family: var(--font-mono); font-size: 26px; font-weight: 800; color: var(--accent-light);
  text-shadow: 0 0 16px var(--accent-glow); margin: 4px 0; }

/* signal rows (digital IO with LED) */
.sig {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--surface-dim); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px;
  transition: border-color 0.2s ease, transform 0.2s var(--spring);
}
.sig:hover { border-color: var(--border-hover); transform: translateX(2px); }
.sig::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--off); opacity: 0.7; border-radius: 2px 0 0 2px; }
.sig.is-on::before    { background: var(--on); }
.sig.is-alarm::before { background: var(--alarm); }
.led { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--offline); }
.sig.is-on .led    { background: var(--on);    box-shadow: 0 0 8px var(--on); }
.sig.is-off .led   { background: var(--off);   box-shadow: 0 0 7px var(--off); }
.sig.is-alarm .led { background: var(--alarm); box-shadow: 0 0 9px var(--alarm); animation: pulse 1.1s infinite; }
.sig .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sig .meta .tag { font-size: 7.5px; color: var(--accent); letter-spacing: 0.18em; font-weight: 700; }
.sig .meta .lbl { font-size: 11px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig .st { font-size: 9px; font-weight: 700; letter-spacing: 0.1em; color: var(--off); }
.sig.is-on .st    { color: var(--on); }
.sig.is-alarm .st { color: var(--alarm); }

/* ---- 3D viewer (always-on center) ---- */
.viewer {
  position: absolute; inset: 0;
  border-radius: var(--radius-lg); overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(0,212,170,0.05) 0%, transparent 60%),
    #06080d;
  border: 1px solid var(--border);
}
.viewer iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer .hint-overlay {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em;
  color: var(--text-secondary); background: rgba(6,8,13,0.6); padding: 5px 13px;
  border: 1px solid var(--border); border-radius: 999px; pointer-events: none; backdrop-filter: blur(5px);
}
.scroll-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.2em; color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: center; gap: 4px; animation: bob 2s infinite; text-decoration: none;
}
.scroll-hint span { font-size: 14px; }
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* control panel (right): output relays + module */
.dev { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--surface-dim); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color 0.2s; }
.dev:hover { border-color: var(--border-hover); }
.dev .led { }
.dev .lbl { flex: 1; font-size: 11px; color: var(--text-primary); letter-spacing: 0.04em; }
.dev .tag { font-size: 8px; color: var(--accent); letter-spacing: 0.16em; font-weight: 700; }
.dev .badge { font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--off); color: var(--off); }
.dev.is-on .badge    { border-color: var(--on); color: var(--on); background: rgba(0,230,118,0.10); }
.dev.is-alarm .badge { border-color: var(--alarm); color: var(--alarm); background: rgba(251,191,36,0.10); }

/* --------------------------------------------------------------- sections */
.section { position: relative; padding: 44px 26px; max-width: 1500px; margin: 0 auto; }
.section h2 { font-size: 12px; letter-spacing: 0.26em; color: #f8fafc; font-weight: 700;
  text-transform: uppercase; margin: 0 0 4px; display: flex; align-items: center; gap: 12px; }
.section h2::before { content: ""; width: 22px; height: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.section .lead { font-size: 10px; color: var(--text-muted); letter-spacing: 0.12em; margin: 0 0 22px; }

/* temperature gauge cards (SVG arc, Honeywell style) */
.temp-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden;
  transition: transform 0.22s var(--spring), border-color 0.2s;
  opacity: 0; transform: translateY(14px);
}
.section.in-view .tcard { opacity: 1; transform: none; }
.tcard:hover { transform: translateY(-2px); border-color: var(--border-hover); }
.tcard::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--tc-color, var(--accent)); opacity: 0.8; box-shadow: 0 0 10px var(--tc-color, var(--accent)); }
.tcard svg { flex: 0 0 auto; }
.arc-bg   { stroke: rgba(255,255,255,0.06); }
.arc-fill { transition: stroke-dashoffset 0.8s var(--spring); filter: drop-shadow(0 0 4px var(--tc-color, var(--accent))); }
.tcard .read { display: flex; flex-direction: column; }
.tcard .read .l { font-size: 8.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); }
.tcard .read .v { font-family: var(--font-mono); font-size: 26px; font-weight: 700; color: var(--tc-color, #fff);
  text-shadow: 0 0 12px color-mix(in srgb, var(--tc-color, var(--accent)) 35%, transparent); }
.tcard .read .u { font-size: 10px; color: var(--text-muted); }

/* evap status tiles */
.evap-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.evap-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; position: relative; overflow: hidden;
  opacity: 0; transform: translateY(14px); transition: transform 0.22s var(--spring), border-color 0.2s, opacity 0.5s;
}
.section.in-view .evap-tile { opacity: 1; transform: none; }
.evap-tile:hover { transform: translateY(-2px); border-color: var(--border-hover); }
.evap-tile .name { font-size: 8.5px; font-weight: 700; letter-spacing: 0.16em; color: var(--text-muted); text-transform: uppercase; }
.evap-tile .t { font-family: var(--font-mono); font-size: 26px; font-weight: 700; color: #fff; margin: 8px 0 2px; }
.evap-tile .s { font-size: 9px; font-weight: 700; letter-spacing: 0.16em; }
.evap-tile.is-on .s    { color: var(--on); }
.evap-tile.is-off .s   { color: var(--off); }
.evap-tile.is-alarm .s { color: var(--alarm); }
.evap-tile .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--on); box-shadow: 0 0 10px var(--on); }
.evap-tile.is-off .bar   { background: var(--off);   box-shadow: 0 0 10px var(--off); }
.evap-tile.is-na .bar    { background: var(--offline); box-shadow: none; }
.evap-tile.is-alarm .bar { background: var(--alarm); box-shadow: 0 0 10px var(--alarm); animation: pulse 1s infinite; }

/* wiring reference */
.wiring { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .wiring { grid-template-columns: 1fr; } }
.evap-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.evap-card .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: rgba(0,212,170,0.05); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: #f8fafc; }
.evap-card .hd .chip { margin-left: auto; font-size: 8.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); }
.evap-card table { width: 100%; border-collapse: collapse; font-size: 11px; }
.evap-card td { padding: 9px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); }
.evap-card tr:last-child td { border-bottom: 0; }
.evap-card td:first-child { color: var(--accent); width: 34px; font-family: var(--font-mono); font-size: 10px; }
.evap-card td:last-child { color: var(--text-muted); text-align: right; font-size: 9px; font-family: var(--font-mono); }

footer { text-align: center; padding: 30px; font-size: 9px; letter-spacing: 0.18em;
  color: var(--text-muted); border-top: 1px solid var(--border); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .cockpit {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "metrics" "center" "left" "right";
    height: auto;
  }
  .cockpit__center { height: 60vh; }
  .cockpit__metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 620px) {
  .cockpit__metrics { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 32px 16px; }
}
