/* ============================================================
   WC26 BOT TRADER — Broadcast TV design system
   สว่าง สดใส แบบกราฟิกถ่ายทอดสดฟุตบอล
   Type: Barlow Condensed (display) / Archivo (body) / IBM Plex Mono (numbers)
   ============================================================ */

:root {
  --bg: #f4f4f0;
  --panel: #ffffff;
  --panel-2: #fafaf7;
  --ink: #14171a;
  --ink-2: #4a5258;
  --ink-3: #8a939a;
  --line: #e4e5e0;
  --line-2: #d2d4cd;
  --chrome: #14171a;   /* broadcast dark blocks (header/scoreboard/quote bar) — dark in BOTH themes */

  --pitch: oklch(0.62 0.17 152);        /* green — up / buy / live */
  --pitch-deep: oklch(0.46 0.14 152);
  --pitch-tint: oklch(0.95 0.035 152);
  --hot: oklch(0.62 0.17 25);           /* red — down / sell */
  --hot-tint: oklch(0.95 0.035 25);
  --sky: oklch(0.62 0.17 255);          /* blue — info / draw */
  --sky-tint: oklch(0.95 0.035 255);
  --gold: oklch(0.78 0.13 85);
  --gold-tint: oklch(0.96 0.05 95);

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Archivo", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "Menlo", monospace;

  --r: 10px;
  --shadow: 0 1px 2px rgba(20,23,26,.05), 0 4px 16px rgba(20,23,26,.06);
  --shadow-lg: 0 2px 4px rgba(20,23,26,.06), 0 12px 32px rgba(20,23,26,.12);
}

/* ---------- dark mode (html.dark · toggled in header · persisted) ---------- */
html.dark {
  --bg: #0e1013;
  --panel: #15181d;
  --panel-2: #1c2026;
  --ink: #e7eaee;
  --ink-2: #b0b8c0;
  --ink-3: #7e8790;
  --line: #262b31;
  --line-2: #353c44;
  --chrome: #07090c;

  --pitch: oklch(0.66 0.15 152);
  --pitch-deep: oklch(0.76 0.13 152);   /* .up text — lighter on dark */
  --pitch-tint: oklch(0.29 0.05 152);
  --hot: oklch(0.68 0.16 25);
  --hot-tint: oklch(0.29 0.06 25);
  --sky: oklch(0.64 0.14 255);
  --sky-tint: oklch(0.27 0.05 255);
  --gold: oklch(0.78 0.13 85);
  --gold-tint: oklch(0.30 0.06 95);

  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.55);
}
html.dark .roundel { border-color: rgba(255,255,255,.55); box-shadow: 0 0 0 1px var(--line-2), 0 1px 3px rgba(0,0,0,.5); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- broadcast type helpers ---------- */
.bc-display {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  line-height: 1;
}
.bc-label {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  color: var(--ink-3);
}
.bc-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.bc-num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.up { color: var(--pitch-deep); }
.down { color: var(--hot); }

/* ---------- lower-third / chevron chip ---------- */
.bc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  padding: 3px 12px;
  color: #fff;
  background: var(--chrome);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.bc-chip.live { background: var(--hot); }
.bc-chip.green { background: var(--pitch); }
.bc-chip.blue { background: var(--sky); }
.bc-chip.gold { background: var(--gold); color: #14171a; }
.bc-chip.ghost { background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); clip-path: none; border-radius: 3px; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 16px;
}
.panel-sub { font-size: 11.5px; color: var(--ink-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--chrome); color: #fff; }
.btn-primary:hover { background: #2a3036; }
.btn-green { background: var(--pitch); color: #fff; }
.btn-green:hover { filter: brightness(1.07); }
.btn-danger { background: var(--hot); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { font-size: 12px; padding: 6px 12px; }

/* ---------- toggle switch ---------- */
.switch {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 99px;
  background: var(--line-2);
  border: none;
  cursor: pointer;
  transition: background .15s ease;
  flex: none;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .15s ease;
}
.switch.on { background: var(--pitch); }
.switch.on::after { left: 19px; }

/* ---------- team roundel ---------- */
.roundel {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  flex: none;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 0 0 1px var(--line-2), 0 1px 3px rgba(0,0,0,.15);
}

/* ---------- nav tabs ---------- */
.nav-tab {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 14px;
  color: rgba(255,255,255,.7);
  background: none;
  border: none;
  padding: 0 14px;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: color .12s ease;
}
.nav-tab:hover { color: #fff; }
.nav-tab.active { color: #fff; }
.nav-tab.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 3px;
  background: var(--pitch);
}

/* ---------- ticker ---------- */
@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  animation: tickerScroll 48s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

/* ---------- order book rows ---------- */
.ob-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.ob-depth {
  position: absolute;
  top: 1px; bottom: 1px;
  border-radius: 2px;
  transition: width .4s ease;
}
.ob-row.ask .ob-depth { right: 0; background: var(--hot-tint); }
.ob-row.bid .ob-depth { right: 0; background: var(--pitch-tint); }
.ob-row > * { position: relative; }

@keyframes flashGreen { 0% { background: var(--pitch-tint); } 100% { background: transparent; } }
@keyframes flashRed { 0% { background: var(--hot-tint); } 100% { background: transparent; } }
.flash-up { animation: flashGreen .8s ease-out; }
.flash-down { animation: flashRed .8s ease-out; }

@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1.4s ease-in-out infinite;
  display: inline-block;
}

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 11px;
  color: var(--ink-3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.tbl td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.tbl tr:last-child td { border-bottom: none; }

/* ---------- misc ---------- */
.clickable { cursor: pointer; transition: background .1s ease, border-color .1s ease, box-shadow .12s ease; }
.clickable:hover { background: var(--panel-2); }
.card-hover:hover { box-shadow: var(--shadow-lg); border-color: var(--line-2); }

input[type="number"].num-input, input[type="text"].num-input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  width: 100px;
  background: var(--panel);
  color: var(--ink);
}
input.num-input:focus { outline: 2px solid var(--sky); outline-offset: -1px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
.app-shell { max-width: 1440px; margin: 0 auto; padding: 20px 24px 40px; }
.hide-scroll { scrollbar-width: none; }
.hide-scroll::-webkit-scrollbar { display: none; }
body.no-hints .thai-hint { display: none; }

@media (max-width: 1020px) {
  .live-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .dash-cols { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 860px) {
  .fixture-row { grid-template-columns: 56px minmax(0, 1fr) auto !important; row-gap: 6px; }
  .fixture-row .fx-odds { display: none !important; }
  .fx-venue { display: none !important; }
}
@media (max-width: 760px) {
  .app-shell { padding: 12px 12px 32px; }
  .header-status { display: none !important; }
  .nav-tab { padding: 0 10px; font-size: 13px; }
  .quote-grid { grid-template-columns: 1fr 1fr !important; row-gap: 14px !important; }
}
