/*
 * assets/styles.css
 * ─────────────────────────────────────────────────────────────────────────────
 * TradeView Pro — Dark Terminal Aesthetic
 * Fonts: JetBrains Mono (mono/data) + Syne (headings/labels)
 * Dash auto-loads all files in /assets — no import needed.
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  --bg-0:        #0a0c10;   /* deepest background                */
  --bg-1:        #0d0f14;   /* chart / panel background          */
  --bg-2:        #13161f;   /* toolbar / control bar             */
  --bg-3:        #1a1d28;   /* button hover / active bg          */
  --border:      #242736;
  --border-hi:   #2e3147;
  --text-muted:  #4a5168;
  --text-body:   #8892a4;
  --text-hi:     #c8d0e0;
  --text-white:  #edf0f7;
  --accent:      #4a90d9;   /* blue — selection / focus          */
  --up:          #00d09c;   /* green — bullish                   */
  --down:        #ff4757;   /* red — bearish                     */
  --warn:        #f0b429;   /* amber — warning / pending         */

  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --font-display:'Syne', 'DM Sans', sans-serif;

  --toolbar-h:   44px;
  --controls-h:  48px;
  --radius:      4px;
  --transition:  140ms ease;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-body);
  font-family: var(--font-mono);
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
}

/* ── App Root ─────────────────────────────────────────────────────────────── */
#app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-0);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ROW 1 — TOOLBAR                                                             */
/* ═══════════════════════════════════════════════════════════════════════════ */
.toolbar-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  padding: 4px 8px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex-shrink: 0;
}

.toolbar-row::-webkit-scrollbar        { height: 4px; }
.toolbar-row::-webkit-scrollbar-thumb  { background: var(--border-hi); border-radius: 2px; }
.toolbar-row::-webkit-scrollbar-track  { background: transparent; }

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-body);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.toolbar-btn .btn-icon {
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
}

.toolbar-btn:hover {
  background: var(--bg-3);
  border-color: var(--border-hi);
  color: var(--text-hi);
}

.toolbar-btn--active,
.toolbar-btn:active {
  background: rgba(74, 144, 217, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-btn--active .btn-icon {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ROW 2 — CONTROLS                                                            */
/* ═══════════════════════════════════════════════════════════════════════════ */
.controls-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: var(--controls-h);
  min-height: var(--controls-h);
  padding: 6px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.control-col { display: flex; align-items: center; }
.control-col--ticker   { flex: 2; min-width: 200px; }
.control-col--interval { flex: 1; min-width: 120px; }
.control-col--message  { flex: 3; min-width: 180px; justify-content: flex-end; }

/* ── Dash Dropdown Overrides ─────────────────────────────────────────────── */
.dash-dropdown .Select-control {
  background: var(--bg-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text-hi) !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  cursor: pointer;
  transition: border-color var(--transition);
}
.dash-dropdown .Select-control:hover { border-color: var(--border-hi) !important; }
.dash-dropdown.is-open .Select-control { border-color: var(--accent) !important; }

.dash-dropdown .Select-value-label { color: var(--text-hi) !important; }
.dash-dropdown .Select-placeholder  { color: var(--text-muted) !important; }
.dash-dropdown .Select-arrow        { border-top-color: var(--text-muted) !important; }

.dash-dropdown .Select-menu-outer {
  background: var(--bg-2) !important;
  border: 1px solid var(--border-hi) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6) !important;
  z-index: 9999 !important;
}
.dash-dropdown .VirtualizedSelectOption { color: var(--text-body) !important; font-size: 12px; }
.dash-dropdown .VirtualizedSelectFocusedOption { background: var(--bg-3) !important; color: var(--text-hi) !important; }

/* ── Message Display ─────────────────────────────────────────────────────── */
.message-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  height: 32px;
  overflow: hidden;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2.4s ease-in-out infinite;
}
.status-dot--live   { background: var(--up); }
.status-dot--error  { background: var(--down); animation: none; }
.status-dot--warn   { background: var(--warn); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.message-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ROW 3 — CHART                                                               */
/* ═══════════════════════════════════════════════════════════════════════════ */
.chart-row {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-1);
  min-height: 0;  /* critical: allows flex child to shrink */
}

.chart-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── OHLCV Legend ────────────────────────────────────────────────────────── */
.chart-legend {
  position: absolute;
  top: 1px;
  left: 1px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 10px;
  background: rgba(13, 15, 20, 0.8);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-body);
  opacity: 0;
  transition: opacity 80ms;
  pointer-events: none;
  z-index: 10;
}

.legend-ticker {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12px;
  color: var(--text-white);
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.legend-item b { font-weight: 600; color: rgba(255, 255, 255, 1.0)}

/* ─── DOM Watermark (v5: built-in watermark option removed) ─────────────── */
.chart-watermark {
  position: absolute;
  bottom: 32px;
  left: 14px;
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.028);
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  line-height: 1;
}

/* ─── Loading State ──────────────────────────────────────────────────────── */
.chart-container::before {
  content: "INITIALIZING CHART...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  pointer-events: none;
}

/* hidden once the canvas renders */
.chart-container canvas ~ *::before,
.chart-container:has(canvas)::before { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* DRAWING TOOLS                                                               */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Override cursor when a drawing tool is active */
.chart-container.drawing-mode,
.chart-container.drawing-mode * {
  cursor: crosshair !important;
}

/* Anchor dot — pulsing indicator shown at the first click point */
.draw-anchor {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 2px solid var(--text-white);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
  animation: anchor-pulse 1s ease-in-out infinite;
}

@keyframes anchor-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 144, 217, 0.6); }
  50%       { box-shadow: 0 0 0 6px rgba(74, 144, 217, 0);  }
}

/* Drawing-mode status badge — top-right of chart */
.chart-container.drawing-mode::after {
  content: "DRAW  ╱";
  position: absolute;
  top: 10px;
  right: 14px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(74, 144, 217, 0.12);
  border: 1px solid rgba(74, 144, 217, 0.35);
  border-radius: var(--radius);
  padding: 3px 8px;
  pointer-events: none;
  z-index: 15;
}

/* Escape hint shown during first anchor wait */
.chart-container.drawing-mode .chart-watermark {
  /* Slightly dim watermark to reduce visual noise during drawing */
  opacity: 0.5;
}
