/* ═══════════════════════════════════════════════════════════════════
   trader.css — layout for public/trader.html
   Depends on shadowflow-dark-tokens.css for variables.
   ═══════════════════════════════════════════════════════════════════ */

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

html, body { margin: 0; padding: 0; }
body.trader-body {
  min-height: 100vh;
  color: var(--sf-fog);
  font-family: var(--sf-font-sans);
}

/* ─── App shell ──────────────────────────────────────────────── */
.trader-shell {
  display: grid;
  grid-template-rows: 52px 1fr 56px;
  grid-template-columns: 1fr;
  min-height: 100vh;
  gap: 0;
}

/* ─── v3 integration: trader band inside the main shell ────────── */
.v3-trader-band {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.v3-trader-band .v3-tape-bar {
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-lg);
  background: linear-gradient(180deg, var(--sf-abyss) 0%, var(--sf-night) 100%);
}
.v3-trader-band .v3-trader-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 12px;
  min-height: 520px;
}
.v3-trader-band .chart-pane { min-height: 520px; }
.v3-trader-band .watch-pane { min-height: 520px; }
.v3-trader-band .v3-trader-status {
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-lg);
  background: var(--sf-abyss);
}
@media (max-width: 900px) {
  .v3-trader-band .v3-trader-grid { grid-template-columns: 1fr; }
}
/* Neutralize the white-corner trap that affects any .shell-region
   wrapper around rounded panels in v3 — none needed here since the
   trader band uses its own rounded children.                      */

/* ─── LIVE TAPE ──────────────────────────────────────────────── */
.tape-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--sf-border);
  background: linear-gradient(180deg, var(--sf-abyss) 0%, var(--sf-night) 100%);
  overflow: hidden;
}
.tape-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--sf-cyan-55);
  border-radius: var(--sf-r-md);
  background: var(--sf-cyan-10);
  color: var(--sf-cyan);
  font-family: var(--sf-font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.tape-track {
  flex: 1;
  min-width: 0;
  overflow: hidden; /* clip marquee strips — no scrollbar, no reflow gap */
  font-family: var(--sf-font-mono);
  font-size: 12px;
  white-space: nowrap;
  min-height: 52px;
  display: flex;
  align-items: center;
}
.tape-track::-webkit-scrollbar { display: none; }

/* ─── Desktop marquee (mirrors mobile .m-tape-bar logic) ─────────────
   Two identical .tape-marquee-strip children scroll together; the outer
   .tape-marquee translates from 0 → -50%, then loops — seamless wrap. */
.tape-bar .tape-marquee {
  display: flex;
  width: max-content;
  animation: tape-scroll 40s linear infinite;
  will-change: transform;
}
.tape-bar .tape-marquee:hover { animation-play-state: paused; }
.tape-bar .tape-marquee-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 10px;
  flex-shrink: 0;
}
/* Tighter within-item spacing on desktop */
.tape-bar .tape-item { gap: 5px; }
/* Fixed-width children prevent strip-width shifts when "—" → real values
   arrive, which would mis-align the -50% wrap and cause a flash. */
.tape-bar .tape-sym  { min-width: 28px; }
.tape-bar .tape-last { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.tape-bar .tape-chg-up,
.tape-bar .tape-chg-down { min-width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
/* Absolute $ change — hidden on mobile, visible on desktop */
.tape-bar .tape-chg-abs {
  display: inline-block;
  min-width: 36px;
  text-align: right;
  margin-right: 2px;
  font-variant-numeric: tabular-nums;
}
/* Vertical divider between symbols */
.tape-bar .tape-sep {
  color: var(--sf-border-2, rgba(255,255,255,0.18));
  font-size: 14px;
  line-height: 1;
  align-self: center;
  user-select: none;
  flex-shrink: 0;
}
@keyframes tape-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .tape-bar .tape-marquee { animation: none; }
}

.tape-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  flex-shrink: 0;
}
.tape-sym {
  color: var(--sf-mist);
  font-weight: 500;
  letter-spacing: 0.05em;
}
.tape-last { color: var(--sf-fog); font-weight: 600; }
.tape-chg-up   { color: var(--sf-up);   font-weight: 500; }
.tape-chg-down { color: var(--sf-down); font-weight: 500; }
.tape-arrow { font-size: 10px; margin-right: 1px; }
.tape-loading {
  color: var(--sf-dust);
  font-family: var(--sf-font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ─── GRID: watch + chart ───────────────────────────────────── */
.trader-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}
@media (max-width: 900px) {
  .trader-grid { grid-template-columns: 1fr; }
}

/* ─── WATCHLIST ──────────────────────────────────────────────── */
.watch-pane {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sf-panel) 0%, #0A0E1A 100%);
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-lg);
  padding: 14px 12px;
  min-height: 0;
}
.watch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--sf-border);
}
.watch-title { color: var(--sf-dust); }
.watch-add-mini {
  width: 22px; height: 22px;
  border-radius: var(--sf-r-sm);
  border: 1px solid var(--sf-border-2);
  background: var(--sf-surface);
  color: var(--sf-mist);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.watch-add-mini:hover {
  border-color: var(--sf-cyan-55);
  color: var(--sf-cyan);
  background: var(--sf-cyan-10);
}

.watch-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 0;
}
.watch-tab {
  padding: 4px 10px;
  border-radius: var(--sf-r-sm);
  border: 0;
  background: transparent;
  color: var(--sf-dust);
  font-family: var(--sf-font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.watch-tab:hover { color: var(--sf-fog); }
.watch-tab.is-active {
  background: var(--sf-surface);
  color: var(--sf-cyan);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.27);
}

.watch-list {
  flex: 1;
  min-height: 0;
  max-height: calc(57px * 9.5 + 8px * 9 + 16px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--sf-border-2) transparent;
}
.watch-list::-webkit-scrollbar { width: 6px; }
.watch-list::-webkit-scrollbar-thumb { background: var(--sf-border-2); border-radius: 3px; }

.watch-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-md);
  background: var(--sf-surface);
  cursor: pointer;
  transition: all var(--sf-t-fast) var(--sf-ease);
  position: relative;
}
.watch-row:hover { border-color: var(--sf-border-3); background: var(--sf-surface-2); }
.watch-row.is-active {
  border-color: var(--sf-cyan-55);
  box-shadow: 0 0 0 1px var(--sf-cyan-55), 0 0 18px -6px rgba(0, 229, 255, 0.5);
}

.watch-badge {
  width: 32px; height: 32px;
  border-radius: var(--sf-r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sf-font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--sf-cyan);
  background: var(--sf-cyan-10);
  border: 1px solid var(--sf-cyan-55);
}
.watch-row[data-dir="down"] .watch-badge { color: var(--sf-down); background: rgba(255,92,122,0.1); border-color: rgba(255,92,122,0.55); }
.watch-row[data-dir="up"]   .watch-badge { color: var(--sf-up);   background: rgba(91,255,176,0.1); border-color: rgba(91,255,176,0.55); }

.watch-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.watch-sym {
  font-family: var(--sf-font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--sf-fog);
  letter-spacing: 0.04em;
}
.watch-tag {
  font-family: var(--sf-font-mono);
  font-size: 10px;
  color: var(--sf-dust);
  letter-spacing: 0.12em;
  margin-top: 2px;
}
.watch-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--sf-font-mono);
}
.watch-last {
  font-size: 14px;
  font-weight: 600;
  color: var(--sf-fog);
  font-variant-numeric: tabular-nums;
}
.watch-chg {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.watch-chg-up   { color: var(--sf-up); }
.watch-chg-down { color: var(--sf-down); }

.watch-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border: 0;
  border-radius: var(--sf-r-xs);
  background: transparent;
  color: var(--sf-haze);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.watch-row:hover .watch-remove { opacity: 1; }
.watch-remove:hover { color: var(--sf-down); background: rgba(255,92,122,0.1); }

/* Drag-and-drop reorder (watch tab only) */
.watch-row[draggable="true"] { cursor: grab; }
.watch-row[draggable="true"]:active { cursor: grabbing; }
.watch-row.is-dragging { opacity: 0.4; }
.watch-row.is-drop-above {
  box-shadow: 0 -2px 0 0 var(--sf-cyan), 0 0 12px -4px rgba(0, 229, 255, 0.6);
}
.watch-row.is-drop-below {
  box-shadow: 0 2px 0 0 var(--sf-cyan), 0 0 12px -4px rgba(0, 229, 255, 0.6);
}

.watch-empty {
  color: var(--sf-dust);
  font-family: var(--sf-font-mono);
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
  letter-spacing: 0.05em;
}

.watch-add {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--sf-border-2);
  border-radius: var(--sf-r-md);
  background: transparent;
  color: var(--sf-mist);
  font-family: var(--sf-font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.watch-add:hover {
  border-color: var(--sf-cyan-55);
  color: var(--sf-cyan);
  background: var(--sf-cyan-10);
}
.watch-add-plus { font-size: 14px; line-height: 1; }

/* ─── CHART ──────────────────────────────────────────────────── */
.chart-pane {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sf-panel) 0%, #0A0E1A 100%);
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-lg);
  min-height: 0;
  overflow: hidden;
}
.chart-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sf-border);
}
.chart-head-left {
  display: flex; align-items: baseline; gap: 10px;
}
.chart-symbol {
  font-family: var(--sf-font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--sf-fog);
  letter-spacing: -0.01em;
}
.chart-tf   { color: var(--sf-cyan); font-size: 12px; }
.chart-subtext { color: var(--sf-dust); font-size: 10px; }

.chart-head-chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-self: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.chart-head-chips::-webkit-scrollbar { display: none; }

.chart-head-tfs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--sf-surface);
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-r-sm);
}
.chart-tf-btn {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--sf-r-xs);
  background: transparent;
  color: var(--sf-dust);
  font-family: var(--sf-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.chart-tf-btn:hover { color: var(--sf-fog); }
.chart-tf-btn.is-active {
  background: var(--sf-cyan-10);
  color: var(--sf-cyan);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.4);
}

.chart-canvas {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--sf-abyss);
}
.chart-canvas iframe { border: 0 !important; }

/* ─── STATUS STRIP ───────────────────────────────────────────── */
.status-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-top: 1px solid var(--sf-border);
  background: var(--sf-abyss);
}
.status-cell {
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border-right: 1px solid var(--sf-border);
}
.status-cell:last-child { border-right: 0; }
.status-label { color: var(--sf-dust); font-size: 10px; }
.status-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sf-font-mono);
  font-size: 13px;
  color: var(--sf-fog);
  letter-spacing: 0.02em;
}

/* ─── ADD SYMBOL DIALOG ──────────────────────────────────────── */
.addsym-layer {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 14, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--sf-z-modal);
}
.addsym-layer.is-open {
  display: flex;
}
.addsym-card {
  width: min(420px, 90vw);
  background: var(--sf-panel);
  border: 1px solid var(--sf-border-2);
  border-radius: var(--sf-r-lg);
  box-shadow: var(--sf-shadow-panel), var(--sf-ring-cyan);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.addsym-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.addsym-close {
  width: 26px; height: 26px;
  border: 0;
  border-radius: var(--sf-r-sm);
  background: transparent;
  color: var(--sf-mist);
  font-size: 18px;
  cursor: pointer;
}
.addsym-close:hover { color: var(--sf-fog); background: var(--sf-surface); }
.addsym-input {
  font-family: var(--sf-font-mono);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.addsym-hint {
  color: var(--sf-haze);
  font-size: 10px;
}
.addsym-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}
.addsym-suggest-chip {
  padding: 4px 10px;
  border: 1px solid var(--sf-border-2);
  border-radius: var(--sf-r-sm);
  background: var(--sf-surface);
  color: var(--sf-mist);
  font-family: var(--sf-font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--sf-t-fast) var(--sf-ease);
}
.addsym-suggest-chip:hover {
  border-color: var(--sf-cyan-55);
  color: var(--sf-cyan);
  background: var(--sf-cyan-10);
}
