/* can_monitor_panel.css — CAN Sensor Remote Monitor (Issue #681) */

*, *::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; }
.logo a { color: inherit; text-decoration: none; }
.logo a:hover { text-decoration: underline; }

#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); }

#hz-display { font-size: 10px; color: var(--text-mid); }

/* ── 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       { padding: 2px 7px; border-radius: 3px; font-weight: bold; border: 1px solid; font-size: 10px; }
.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; font-size: 10px; }

/* ── Dashboard grid ── */
#dashboard {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  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; } }

.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.border-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; gap: 6px;
}

/* ── Big numerics ── */
.big-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.big-metric { display: flex; flex-direction: column; }
.big-label  { font-size: 9px; color: var(--text-mid); margin-bottom: 1px; }
.big-num    { font-size: 28px; font-weight: bold; font-family: monospace; line-height: 1; }
.big-unit   { font-size: 11px; color: var(--text-mid); }

/* ── Gauge bar (unidirectional) ── */
.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-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.3s ease, background 0.3s ease;
}

/* ── Bidirectional bar ── */
.bidir-row   { display: flex; flex-direction: column; gap: 3px; }
.bidir-label-row { display: flex; justify-content: space-between; font-size: 10px; }
.bidir-track {
  width: 100%; height: 8px; position: relative;
  background: var(--bg2); border-radius: 4px;
  border: 1px solid var(--border2); overflow: hidden;
}
.bidir-track::after {
  content: ''; position: absolute;
  left: 50%; top: 0; width: 1px; height: 100%;
  background: var(--border2);
}
.bidir-fill {
  position: absolute; top: 0; height: 100%;
  transition: left 0.3s ease, width 0.3s ease, background 0.3s ease;
  border-radius: 2px;
}

/* ── Stat grid ── */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.stat-cell {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 5px; padding: 5px 6px; text-align: center;
}
.stat-lbl { font-size: 8px; color: var(--text-mid); margin-bottom: 2px; }
.stat-val { font-size: 13px; font-weight: bold; font-family: monospace; }

.stat-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }

/* ── Live dot ── */
.ts-row { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-mid); margin-top: 2px; }
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0; transition: background 0.2s;
}
.live-dot.active { background: var(--cyan); }

/* ── Canvas ── */
canvas {
  display: block;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--bg0);
}
