/* diagnostics_panel.css — Saltybot System Diagnostics Dashboard (Issue #562) */

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

:root {
  --bg0:       #050510;
  --bg1:       #070712;
  --bg2:       #0a0a1a;
  --border:    #0c2a3a;
  --border2:   #1e3a5f;
  --text-dim:  #374151;
  --text-mid:  #6b7280;
  --text-base: #9ca3af;
  --text-hi:   #d1d5db;
  --cyan:      #06b6d4;
  --cyan-dim:  #0e4f69;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --orange:    #f97316;
}

body {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  background: var(--bg0);
  color: var(--text-base);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}
.logo { color: #f97316; font-weight: bold; letter-spacing: 0.15em; font-size: 13px; }

#conn-bar { display: flex; align-items: center; gap: 6px; }
#conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0; transition: background 0.3s;
}
#conn-dot.connected { background: var(--green); }
#conn-dot.error     { background: var(--red); animation: blink 1s infinite; }

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

#ws-input {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 4px;
  color: #67e8f9; padding: 2px 8px; font-family: monospace; font-size: 11px; width: 200px;
}
#ws-input:focus { outline: none; border-color: var(--cyan); }

.hdr-btn {
  padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border2);
  background: var(--bg2); color: #67e8f9; font-family: monospace;
  font-size: 10px; font-weight: bold; cursor: pointer; transition: background 0.15s;
}
.hdr-btn:hover { background: var(--cyan-dim); }

#refresh-info {
  font-size: 10px; color: var(--text-mid);
  display: flex; align-items: center; gap: 4px;
}
#refresh-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); transition: background 0.2s;
}
#refresh-dot.pulse { background: var(--cyan); animation: blink 0.4s; }

/* ── Status bar ── */
#status-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 16px; background: var(--bg1);
  border-bottom: 1px solid var(--border); font-size: 10px; flex-wrap: wrap;
}
.sys-badge {
  padding: 2px 8px; border-radius: 3px; font-weight: bold;
  border: 1px solid; letter-spacing: 0.05em;
}
.badge-ok    { background: #052e16; border-color: #166534; color: #4ade80; }
.badge-warn  { background: #451a03; border-color: #92400e; color: #fcd34d; }
.badge-error { background: #450a0a; border-color: #991b1b; color: #f87171; animation: blink 1s infinite; }
.badge-stale { background: #111827; border-color: #374151; color: #6b7280; }
#last-update { color: var(--text-mid); margin-left: auto; }

/* ── Dashboard grid ── */
#dashboard {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto;
  gap: 12px;
  padding: 12px;
  align-content: start;
  overflow-y: auto;
}

@media (max-width: 1024px) { #dashboard { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { #dashboard { grid-template-columns: 1fr; } }

/* Spanning cards */
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }

/* ── Card ── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.alert-warn  { border-color: #92400e; }
.card.alert-error { border-color: #991b1b; }

.card-title {
  font-size: 9px; font-weight: bold; letter-spacing: 0.15em;
  color: #0891b2; text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .badge { font-size: 9px; padding: 1px 6px; border-radius: 3px; }

/* ── Gauge bar ── */
.gauge-row {
  display: flex; flex-direction: column; gap: 3px;
}
.gauge-label-row {
  display: flex; justify-content: space-between; font-size: 10px;
}
.gauge-label { color: var(--text-mid); }
.gauge-value { font-family: monospace; }
.gauge-track {
  width: 100%; height: 8px;
  background: var(--bg2); border-radius: 4px;
  overflow: hidden; border: 1px solid var(--border2);
}
.gauge-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.5s ease, background 0.5s ease;
}

/* ── Big metric ── */
.big-metric {
  display: flex; align-items: baseline; gap: 4px;
}
.big-num { font-size: 28px; font-weight: bold; font-family: monospace; }
.big-unit { font-size: 11px; color: var(--text-mid); }

/* ── Sparkline ── */
#batt-sparkline {
  width: 100%; border-radius: 4px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  display: block;
}

/* ── Node list ── */
.node-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 0; border-bottom: 1px solid var(--border);
  font-size: 10px;
}
.node-row:last-child { border-bottom: none; }
.node-name { color: var(--text-base); font-family: monospace; }
.node-status {
  padding: 1px 6px; border-radius: 3px; font-size: 9px; font-weight: bold;
}
.ns-ok    { background: #052e16; color: #4ade80; }
.ns-warn  { background: #451a03; color: #fcd34d; }
.ns-error { background: #450a0a; color: #f87171; }
.ns-stale { background: #111827; color: #6b7280; }

/* ── Temp arc display ── */
.temp-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
}
.temp-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 6px; text-align: center;
}
.temp-label { font-size: 9px; color: var(--text-mid); margin-bottom: 2px; }
.temp-value { font-size: 22px; font-weight: bold; font-family: monospace; }
.temp-bar-track {
  margin-top: 4px; width: 100%; height: 4px;
  background: var(--bg0); border-radius: 2px; overflow: hidden;
}
.temp-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

/* ── Motor section ── */
.motor-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.motor-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 8px;
}
.motor-label { font-size: 9px; color: var(--text-mid); margin-bottom: 4px; }

/* ── WiFi bars ── */
.rssi-bars { display: flex; align-items: flex-end; gap: 3px; }
.rssi-bar { width: 6px; border-radius: 2px 2px 0 0; }

/* ── MQTT indicator ── */
.mqtt-status { display: flex; align-items: center; gap: 6px; }
.mqtt-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-dim); transition: background 0.3s;
}
.mqtt-dot.connected { background: var(--green); animation: none; }
.mqtt-dot.disconnected { background: var(--red); animation: blink 1s infinite; }

/* ── Footer ── */
#footer {
  background: var(--bg1); border-top: 1px solid var(--border);
  padding: 4px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; font-size: 10px; color: var(--text-dim);
}
