/* ==========================================================================
   Cyberpunk Server Dashboard — styles.css
   Fully self-hosted: fonts are local (@font-face below), no CDNs.
   ========================================================================== */

@font-face {
  font-family: "JetBrains Mono Local";
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono Local";
  src: url("fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   DEFAULT PALETTE.
   Don't edit this block to recolour the dashboard — override it in theme.css,
   which loads after this file and survives updates to styles.css.

   Accent colours are declared as raw "R G B" channels so every border, glow
   and gradient in the stylesheet can derive its own alpha from them via
   rgb(var(--accent-rgb) / 0.35). Change the channel, and all 28 derived
   colours follow.
   -------------------------------------------------------------------------- */
:root {
  /* Accent channels — the four knobs that define the mood */
  --accent-rgb: 0 255 245;        /* primary   : cyan  */
  --accent-alt-rgb: 255 43 214;   /* secondary : magenta */
  --warn-rgb: 255 183 0;          /* warning   : amber */
  --ok-rgb: 57 255 136;           /* healthy   : green */
  --alert-rgb: 255 59 92;         /* critical  : red   */

  /* Solid forms of the above */
  --accent: rgb(var(--accent-rgb));
  --accent-alt: rgb(var(--accent-alt-rgb));
  --warn: rgb(var(--warn-rgb));
  --ok: rgb(var(--ok-rgb));
  --alert: rgb(var(--alert-rgb));

  /* Semantic aliases used throughout the stylesheet */
  --cyan: var(--accent);
  --cyan-dim: rgb(var(--accent-rgb) / 0.65);
  --magenta: var(--accent-alt);
  --amber: var(--warn);
  --green: var(--ok);
  --red: var(--alert);
  --border-cyan: rgb(var(--accent-rgb) / 0.35);

  /* Surfaces and text */
  --bg-void: #05070c;
  --bg-panel: rgba(10, 18, 28, 0.55);
  --bg-panel-solid: #0a1220;
  --text-primary: #d9fbff;
  --text-dim: #6f97a3;

  /* Effects */
  --scanline-opacity: 0.18;
  --noise-opacity: 0.035;
  --glow-strength: 1;

  --font-mono: "JetBrains Mono Local", ui-monospace, "Cascadia Mono", "Share Tech Mono",
    Consolas, "SFMono-Regular", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgb(var(--accent-rgb) / 0.07), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgb(var(--accent-alt-rgb) / 0.06), transparent 55%),
    var(--bg-void);
}

::selection {
  background: var(--cyan);
  color: #000;
}

/* ---------------- Overlays: scanlines / vignette / noise ---------------- */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgb(0 0 0 / var(--scanline-opacity)) 2px,
    rgba(0, 0, 0, 0) 3px
  );
  mix-blend-mode: overlay;
  animation: scan-drift 9s linear infinite;
}
@keyframes scan-drift {
  0% { background-position-y: 0; }
  100% { background-position-y: 100px; }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  box-shadow: inset 0 0 220px rgba(0, 0, 0, 0.85);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 98;
  opacity: var(--noise-opacity);
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 3px 3px;
}

/* -------------------------------- Layout -------------------------------- */
.hud {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Angled "HUD frame" corners via clip-path, plus a glowing border */
.hex-frame {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-cyan);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  clip-path: polygon(
    16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%,
    0 100%, 0 16px
  );
  box-shadow:
    0 0 0 1px rgb(var(--accent-rgb) / 0.05) inset,
    0 0 18px rgb(var(--accent-rgb) / 0.06),
    0 4px 24px rgba(0, 0, 0, 0.4);
}
.hex-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: polygon(
    16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%,
    0 100%, 0 16px
  );
  border: 1px solid transparent;
  background:
    linear-gradient(135deg, rgb(var(--accent-rgb) / 0.5), transparent 30%, transparent 70%, rgb(var(--accent-alt-rgb) / 0.35))
    border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* ------------------------------- Header --------------------------------- */
.hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 26px 12px 18px;
  flex-shrink: 0;
  gap: 20px;
}

.header-left {
  flex: 0 0 auto;
  min-width: 0;
}
.alias {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgb(var(--accent-rgb) / 0.7), 0 0 22px rgb(var(--accent-rgb) / 0.35);
}
.hostname {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.hostname span { color: var(--text-primary); }

.header-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
}
/* A GRID, not a wrapping flex row. Wrapping produced a ragged, centred
   staircase (one spec on the first line, two on the next...); fixed column
   counts keep the block aligned at every width. Tracks are minmax(0, auto):
   they size to their content when there is room, and only the specs that
   actually overflow get truncated. */
.spec-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  justify-content: center;
  align-items: center;
  gap: 2px clamp(16px, 2.4vw, 52px);
  width: 100%;
}
.spec {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.spec-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
}
.spec-value {
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-top: 2px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.header-right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.clock {
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  text-shadow: 0 0 6px rgb(var(--accent-rgb) / 0.4);
}
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  transition: background 0.3s, box-shadow 0.3s;
}
.conn-status.live .conn-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
.conn-status.live .conn-text { color: var(--green); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* -------------------------------- Grid ----------------------------------- */
/* Row 1 is one wide VITALS band (CPU/RAM/SWAP/DISK together — they read as
   a single glance-able status line). Row 2 holds the detail panels. */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Row 1 (vitals) sizes to its CONTENT; row 2 takes whatever is left. A
     fixed fraction there was what made the band overlap on narrow screens
     and sit half-empty on wide ones. */
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}
.panel-vitals { grid-column: 1 / -1; grid-row: 1; }
.panel-net   { grid-column: 1; grid-row: 2; }
.panel-docker{ grid-column: 2; grid-row: 2; }
.panel-proc  { grid-column: 3; grid-row: 2; }

/* Every panel is a CONTAINER, and readouts inside are sized in `cqw`, so
   gauges and text scale with the panel that holds them rather than against
   a fixed root font-size — that's what keeps things legible on a large
   kiosk display instead of shrinking into a corner. */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 12px 16px 16px;
  /* inline-size, NOT size: a size container must have a fixed height, which
     forces content to overlap or get clipped when it doesn't fit. Sizing off
     width alone lets panels grow to their content instead. */
  container-type: inline-size;
  overflow: hidden;
  /* Shared type scale, panel-relative */
  --info: clamp(0.8rem, 3cqw, 1.3rem);
  --info-lg: clamp(0.9rem, 3.6cqw, 1.6rem);
  --label: clamp(0.62rem, 2.2cqw, 0.95rem);
}

.panel-title {
  font-size: clamp(0.72rem, 2.2cqw, 1rem);
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-shadow: 0 0 6px rgb(var(--accent-rgb) / 0.5);
  border-bottom: 1px solid rgb(var(--accent-rgb) / 0.18);
  padding-bottom: 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* -------------------------------- Gauges --------------------------------- */
/* Each panel sets its own --gauge-size in `cq` units; everything inside the
   ring (value text, sub-label) is derived from it, so a gauge always reads
   correctly proportioned no matter how large the panel gets. */
.gauge-wrap {
  position: relative;
  width: var(--gauge-size, 120px);
  height: var(--gauge-size, 120px);
  flex-shrink: 0;
}
.gauge-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.gauge-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.gauge-value {
  font-size: calc(var(--gauge-size, 120px) * 0.27);
  line-height: 1;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 10px rgb(var(--accent-rgb) / 0.55);
}
.gauge-sub {
  font-size: calc(var(--gauge-size, 120px) * 0.105);
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-top: calc(var(--gauge-size, 120px) * 0.05);
}

/* Shared readout rows */
.detail-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: var(--info);
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.detail-line span:last-child {
  color: var(--text-primary);
  font-weight: 700;
  white-space: nowrap;
}

.line-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
}

/* =========================== SYSTEM VITALS band ==========================
   The body is an explicit 2-row GRID, not a flex column. Both rows are
   minmax(0, Nfr), so the gauges can never grow enough to squeeze the lower
   half out of the panel — each row gets a guaranteed share of the height
   and its contents scale down to fit it. */
.panel-vitals {
  /* All widths now: the band is full-bleed, so cqw is a stable basis and
     the px caps keep an ultrawide screen from inflating everything. */
  /* Slightly larger than the visible ring: the canvas also has to hold the
     glow margin reserved in charts.js. */
  --gauge-size: clamp(104px, 10.3cqw, 196px);
  --info: clamp(0.85rem, 1.5cqw, 1.35rem);
  --label: clamp(0.65rem, 1.05cqw, 0.95rem);
}
.vitals-body {
  display: grid;
  grid-template-rows: auto auto;
  gap: clamp(10px, 1.4cqw, 24px);
}
.vitals-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.6cqw, 26px);
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 0.9cqw, 16px);
  min-width: 0;
}
/* Hairline dividers keep the four readouts visually separate without
   needing four separately framed panels. */
.stat + .stat {
  border-left: 1px solid rgb(var(--accent-rgb) / 0.14);
}
.stat-detail {
  width: 100%;
  max-width: 22ch;
  display: flex;
  flex-direction: column;
  gap: clamp(3px, 0.5cqw, 9px);
  padding: 0 clamp(4px, 1cqw, 16px);
}
.stat-cpu  .gauge-sub { color: var(--cyan); }
.stat-ram  .gauge-sub { color: var(--magenta); }
.stat-swap .gauge-sub { color: var(--amber); }
.stat-disk .gauge-sub { color: var(--green); }

.vitals-lower {
  display: grid;
  /* chart on the left, cores strip on the right */
  grid-template-columns: 1fr 1.6fr;
  gap: clamp(10px, 2cqw, 28px);
  align-items: start;
  /* Matches the hairline between the stat columns above. */
  border-top: 1px solid rgb(var(--accent-rgb) / 0.14);
  padding-top: clamp(10px, 1.4cqw, 22px);
}
.vitals-chart {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Explicit height: the canvas has no intrinsic size to stretch against now
   that the panel isn't height-constrained. */
.vitals-chart .line-canvas {
  flex: none;
  height: clamp(76px, 8cqw, 150px);
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: var(--label);
  letter-spacing: 0.12em;
  flex-shrink: 0;
}
.lg-cpu { color: var(--cyan); }
.lg-ram { color: var(--magenta); }
.title-spacer { flex: 1; }
.cores-count {
  color: var(--text-dim);
  letter-spacing: 0.12em;
}
/* Per-core strip. Rows are auto-height and the grid is free to grow, so ALL
   cores are always visible — your 16-core host was showing only the first 8
   because extra rows were clipped by a fixed-height container. */
/* Column count is set from JS (see coreColumns in app.js) so the block is
   always even — 4 wide until that needs more than 4 rows, then wider. */
.cores-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: clamp(5px, 0.8cqw, 12px) clamp(10px, 1.6cqw, 26px);
  /* Centre the block of rows against the chart beside it, rather than
     letting it hang from the top of a taller cell. */
  align-content: center;
  /* Same hairline as the stat columns and the band divider above. */
  border-left: 1px solid rgb(var(--accent-rgb) / 0.14);
  padding-left: clamp(10px, 1.6cqw, 26px);
  align-self: stretch;
}
/* Fixed label/value columns: "C1" and "C15" must reserve the same width, or
   the bars come out different lengths row to row. */
.core {
  display: grid;
  grid-template-columns: 3.4ch 1fr 4.2ch;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.core-id,
.core-pct {
  font-size: var(--label);
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.core-pct {
  color: var(--text-primary);
  text-align: right;
}
.core-bar {
  height: clamp(6px, 0.65cqw, 12px);
  border-radius: 2px;
  background: rgb(var(--accent-rgb) / 0.12);
  overflow: hidden;
  position: relative;
}
.core-bar-fill {
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  transition: width 0.4s ease;
}

/* -------------------------------- Network panel ---------------------------- */
.net-body {
  flex-direction: column;
  gap: 10px;
}
.net-readouts {
  display: flex;
  gap: 24px;
}
.net-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}
.net-stat.up { color: var(--magenta); text-shadow: 0 0 8px rgb(var(--accent-alt-rgb) / 0.5); }
.net-stat.down { color: var(--cyan); text-shadow: 0 0 8px rgb(var(--accent-rgb) / 0.5); }
.net-arrow { font-size: 0.8rem; }
.net-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  font-weight: 400;
}

/* -------------------------------- Docker panel ---------------------------- */
.count-badge {
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.count-badge.running {
  color: var(--green);
  background: rgb(var(--ok-rgb) / 0.1);
  border: 1px solid rgb(var(--ok-rgb) / 0.4);
}
.count-badge.stopped {
  color: var(--red);
  background: rgb(var(--alert-rgb) / 0.1);
  border: 1px solid rgb(var(--alert-rgb) / 0.4);
}

.docker-body { flex-direction: column; }
.container-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
/* Each row is its own grid, so `auto` tracks would size per-row and the
   badge would land at a different x on every line. Fixed ch tracks (plus
   tabular figures) keep the stat and badge columns aligned down the list. */
.container-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 6.5ch 9ch 11ch;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgb(var(--accent-rgb) / 0.04);
  border: 1px solid rgb(var(--accent-rgb) / 0.1);
  border-radius: 3px;
  font-size: 0.68rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.restarting { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: pulse 1s infinite; }
.status-dot.exited, .status-dot.stopped { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.paused { background: var(--text-dim); }

.c-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.c-badge {
  font-size: 0.56rem;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: 0.06em;
  border: 1px solid currentColor;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.c-badge.running { color: var(--green); }
.c-badge.healthy { color: var(--green); }
.c-badge.unhealthy { color: var(--red); }
.c-badge.restarting { color: var(--amber); }
.c-badge.exited, .c-badge.stopped { color: var(--red); }
.c-stat {
  color: var(--text-dim);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- Process table ---------------------------- */
.proc-body { overflow-y: auto; }
.proc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
}
.proc-table th {
  text-align: left;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  font-weight: 400;
  font-size: 0.58rem;
  padding: 4px 6px;
  border-bottom: 1px solid rgb(var(--accent-rgb) / 0.15);
  position: sticky;
  top: 0;
  background: var(--bg-panel-solid);
}
.proc-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgb(var(--accent-rgb) / 0.06);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 1px;
}
.proc-table td:nth-child(3), .proc-table td:nth-child(4) { color: var(--cyan); }

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  width: 100%;
}

/* -------------------------------- Scrollbars ------------------------------ */
* {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--accent-rgb) / 0.4) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb {
  background: rgb(var(--accent-rgb) / 0.35);
  border-radius: 3px;
}

/* -------------------------------- Responsive ------------------------------ */
/* The four vitals stay four-across well below 1200px — the gauges scale with
   the panel width, so they only need stacking on genuinely small screens. */
@media (max-width: 1200px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(180px, 1fr) minmax(180px, 1fr);
  }
  .panel-vitals { grid-column: 1 / 3; grid-row: 1; }
  .panel-net   { grid-column: 1; grid-row: 2; }
  .panel-docker{ grid-column: 2; grid-row: 2; }
  .panel-proc  { grid-column: 1 / 3; grid-row: 3; }
  html, body { overflow-y: auto; }
  .hud { height: auto; min-height: 100vh; }
}

/* Below this the four specs can't sit on one line without shrinking to
   nonsense, so drop to a tidy 2x2 block rather than letting them wrap. */
@media (max-width: 1150px) {
  .spec-row {
    grid-template-columns: repeat(2, minmax(0, auto));
    gap: 6px clamp(20px, 4vw, 60px);
  }
}

@media (max-width: 880px) {
  .vitals-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  /* Single column: the cores strip sits below the chart, so its divider
     would be a stray vertical line. */
  .vitals-lower { grid-template-columns: 1fr; }
  .cores-grid {
    border-left: 0;
    padding-left: 0;
    padding-top: clamp(8px, 2vw, 16px);
    border-top: 1px solid rgb(var(--accent-rgb) / 0.14);
  }
}

/* Very narrow: the specs block goes single-column and the header stacks. */
@media (max-width: 620px) {
  .hud-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .header-right { align-items: flex-start; }
  .spec-row { grid-template-columns: minmax(0, 1fr); }
  .spec { align-items: flex-start; }
}
