/* =============================================================
   TradingBoT Terminal — design system
   Bloomberg-dense layout + phosphor accents + monospace type
   ============================================================= */

/* Grid utility: panel spans both columns (used on Symbols page where
   Focus + Depth share row 1 and Indicators spans the full width below). */
.panel.span-2 { grid-column: 1 / -1; }

:root {
  /* Near-black backgrounds, layered */
  --bg-0: #05070a;          /* page */
  --bg-1: #0a0d12;          /* panel */
  --bg-2: #0e1218;          /* panel raised */
  --bg-3: #141921;          /* input / header */
  --bg-hover: #1a1f2a;

  /* Structural */
  --border: #1c2230;
  --border-strong: #2a3244;
  --grid: #11161f;

  /* Text */
  --fg: #d4d8df;
  --fg-bright: #f2f4f7;
  --fg-dim: #8691a4;
  --fg-faint: #4a5264;

  /* Phosphor accents (the terminal DNA) */
  --amber: #ffb020;         /* primary accent / selection */
  --amber-dim: #8a5f10;
  --phosphor: #22d66f;      /* up / live / ok */
  --phosphor-dim: #145a31;
  --red: #ff4d4d;           /* down / danger */
  --red-dim: #7a1e1e;
  --cyan: #4fd9ff;          /* info / links */
  --violet: #b78bff;        /* claude / AI */
  --yellow: #f5d14a;        /* warn */
  --rose: #ff6da6;          /* personalisation accent option */

  /* User-configurable accent (overridden at runtime by user preferences).
     Defaults to amber to match the terminal DNA; the Profile page lets the
     user pick violet / cyan / amber / green / rose. */
  --accent: var(--amber);
  --accent-fg: var(--bg-0);  /* readable text colour on a filled accent button */

  /* Semantic */
  --up: var(--phosphor);
  --down: var(--red);
  --warn: var(--yellow);
  --critical: #ff3860;

  /* Type */
  --mono: "JetBrains Mono", "IBM Plex Mono", "Menlo", "Consolas", monospace;
  --sans: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Density mode — applied via document.documentElement.dataset.density.
   Compact halves the panel header / body padding for users who want more
   rows on screen. */
:root[data-density="compact"] .panel-body  { padding: 4px; }
:root[data-density="compact"] .panel-head  { padding: 3px 8px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "calt" 0, "liga" 0;
  overflow: hidden;
  height: 100vh;
}

#root { height: 100vh; overflow: hidden; }

/* ---------------- scrollbars ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--border); border: 2px solid var(--bg-0); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Vertical stack of panels that should keep natural height and let the
   column scroll instead of squishing children. Panel's default height:100%
   (inline) is overridden so each child sizes to its content. */
.scroll-stack > * { flex-shrink: 0; height: auto !important; }

/* ---------------- text utilities ---------------- */
.mono { font-family: var(--mono); }
.sans { font-family: var(--sans); }
.up { color: var(--up); }
.down { color: var(--down); }
.dim { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.bright { color: var(--fg-bright); }
.amber { color: var(--amber); }
.cyan { color: var(--cyan); }
.violet { color: var(--violet); }
.warn { color: var(--warn); }
.upper { text-transform: uppercase; letter-spacing: 0.06em; }
.tnum { font-variant-numeric: tabular-nums; }

.h-xxs { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-dim); }
.h-xs { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-dim); }
.h-lg { font-size: 22px; font-weight: 500; color: var(--fg-bright); letter-spacing: -0.01em; }
.h-xl { font-size: 32px; font-weight: 500; color: var(--fg-bright); letter-spacing: -0.02em; }

/* ---------------- panels ---------------- */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  position: relative;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  height: 26px;
  flex-shrink: 0;
}
.panel-header .title { color: var(--amber); font-weight: 500; }
.panel-header .actions { display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 10px; }
.panel-body-flush { padding: 0; }

/* Vertical resize handle for resizable side panels */
.resize-handle-v {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background 120ms;
}
.resize-handle-v:hover  { background: var(--border-strong); }
.resize-handle-v:active { background: var(--amber); }

/* A single-digit watermark number in the top-right of panel headers, Bloomberg-y */
.panel-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--amber);
  color: var(--bg-0);
  font-weight: 700;
  font-size: 9px;
  padding: 1px 5px;
  letter-spacing: 0.05em;
}

/* ---------------- pills / badges ---------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  line-height: 1.4;
  white-space: nowrap;
}
.pill.solid { background: currentColor; }
.pill.solid > * { color: var(--bg-0); }
.pill-up { color: var(--up); background: rgba(34, 214, 111, 0.08); }
.pill-down { color: var(--down); background: rgba(255, 77, 77, 0.08); }
.pill-amber { color: var(--amber); background: rgba(255, 176, 32, 0.08); }
.pill-cyan { color: var(--cyan); background: rgba(79, 217, 255, 0.08); }
.pill-violet { color: var(--violet); background: rgba(183, 139, 255, 0.1); }
.pill-dim { color: var(--fg-dim); background: transparent; }
.pill-red-solid { color: var(--bg-0); background: var(--red); border-color: var(--red); font-weight: 600; }
.pill-amber-solid { color: var(--bg-0); background: var(--amber); border-color: var(--amber); font-weight: 600; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  transition: all 80ms;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--fg-bright); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-danger { background: var(--red); border-color: var(--red); color: var(--bg-0); }
.btn-danger:hover { background: #ff6b6b; border-color: #ff6b6b; color: var(--bg-0); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--border); }
.btn-up { color: var(--up); border-color: var(--phosphor-dim); }
.btn-up:hover { background: rgba(34, 214, 111, 0.1); border-color: var(--up); color: var(--up); }
.btn-down { color: var(--down); border-color: var(--red-dim); }
.btn-down:hover { background: rgba(255, 77, 77, 0.1); border-color: var(--down); color: var(--down); }
.btn-sm { padding: 2px 6px; font-size: 10px; }
.btn-xs { padding: 1px 4px; font-size: 9px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--amber-dim); color: var(--fg-bright); }
.chip.active { background: var(--amber); color: var(--bg-0); border-color: var(--amber); font-weight: 600; }

/* ---------------- inputs ---------------- */
.input, .select {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--fg-bright);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  outline: none;
  transition: border-color 80ms;
}
.input:focus, .select:focus { border-color: var(--amber); }
.input::placeholder { color: var(--fg-faint); }
.input-lg { font-size: 13px; padding: 8px 10px; }
.label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 3px;
}
.checkbox {
  appearance: none;
  width: 12px; height: 12px;
  background: var(--bg-0);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  position: relative;
  margin: 0;
  flex-shrink: 0;
}
.checkbox:checked { background: var(--amber); border-color: var(--amber); }
.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid var(--bg-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------------- tables ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.tbl th {
  text-align: left;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.tbl td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
.tbl tr:hover td { background: var(--bg-2); }
.tbl tr.selected td { background: rgba(255, 176, 32, 0.08); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-compact td, .tbl-compact th { padding: 3px 8px; }

/* ---------------- key-value grid ---------------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 11px; }
.kv dt { color: var(--fg-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.kv dd { margin: 0; color: var(--fg-bright); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- flash animations for ticking numbers ---------------- */
@keyframes flash-up {
  0% { background: rgba(34, 214, 111, 0.35); }
  100% { background: transparent; }
}
@keyframes flash-down {
  0% { background: rgba(255, 77, 77, 0.35); }
  100% { background: transparent; }
}
.flash-up { animation: flash-up 600ms ease-out; }
.flash-down { animation: flash-down 600ms ease-out; }

/* Pulsing dot for live state */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}
.dot-live { background: var(--up); color: var(--up); animation: pulse-dot 1.6s infinite; }
.dot-warn { background: var(--warn); color: var(--warn); }
.dot-critical { background: var(--critical); color: var(--critical); animation: pulse-dot 0.8s infinite; }
.dot-dim { background: var(--fg-faint); color: var(--fg-faint); }

/* Scanline / phosphor glow overlay — subtle */
.phosphor-text {
  color: var(--phosphor);
  text-shadow: 0 0 4px rgba(34, 214, 111, 0.4);
}
.amber-text {
  color: var(--amber);
  text-shadow: 0 0 4px rgba(255, 176, 32, 0.25);
}

/* ---------------- ASCII-style dividers ---------------- */
.rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}
.rule-dashed {
  border: 0;
  border-top: 1px dashed var(--border-strong);
  margin: 0;
}

/* ---------------- layout helpers ---------------- */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.sep { width: 1px; height: 14px; background: var(--border); }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Blink caret ---------------- */
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.caret::after {
  content: "▊";
  display: inline-block;
  margin-left: 2px;
  color: var(--amber);
  animation: blink 1s step-end infinite;
}

/* CRT-ish background grid — very faint */
.bg-grid {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 40px 60px rgba(0, 0, 0, 0.6);
}

/* Sparkline container */
.spark {
  display: inline-block;
  vertical-align: middle;
}

/* Focus ring for keyboard users */
:focus-visible { outline: 1px solid var(--amber); outline-offset: 1px; }

/* Small link style */
.link {
  color: var(--cyan);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.link:hover { color: var(--fg-bright); }
