/* ═══════════════════════════════════════════════════════════════
   AXION TERMINAL — Markets Overview Dashboard
   Institutional-grade dark mode with D3.js + WebSocket integration
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Override layer) ────────────────── */
:root {
  --ov-bg:         #0B0B0B;
  --ov-surface:    #141414;
  --ov-surface-2:  #1A1A1A;
  --ov-surface-3:  #222222;
  --ov-border:     #2A2A2A;
  --ov-border-2:   #333333;
  --ov-lime:       #D3FB03;
  --ov-green:      #00FF00;
  --ov-red:        #FF0000;
  --ov-coral:      #FF2A55;
  --ov-amber:      #FFB800;
  --ov-cyan:       #00E5FF;
  --ov-blue:       #4488FF;
  --ov-t1:         #F0F0F0;
  --ov-t2:         #A0A0A0;
  --ov-t3:         #606060;
  --ov-mono:       'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --ov-sans:       'Inter', -apple-system, sans-serif;
  --ov-glow-green: 0 0 8px rgba(0, 255, 0, 0.4);
  --ov-glow-red:   0 0 8px rgba(255, 0, 0, 0.4);
  --ov-glow-lime:  0 0 12px rgba(211, 251, 3, 0.3);
  --ov-glow-cyan:  0 0 10px rgba(0, 229, 255, 0.3);
}

/* ═══════════════════════════════════════════════
   MASTER GRID LAYOUT
   ═══════════════════════════════════════════════ */

.axion-overview {
  width: 100%;
  min-height: 100%;
  background: var(--ov-bg);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-family: var(--ov-sans);
  color: var(--ov-t1);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Top Section: 3-Column Dashboard Grid ──────────────── */
.ov-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 0.7fr 1fr;
  grid-template-rows: auto;
  gap: 1px;
  background: var(--ov-border);
  border: 1px solid var(--ov-border);
}

/* ── Panel Base ──────────────────────────────────────────── */
.ov-panel {
  background: var(--ov-surface);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}

.ov-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ov-border-2), transparent);
}

.ov-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ov-border);
}

.ov-panel-title {
  font-family: var(--ov-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ov-t2);
}

.ov-panel-badge {
  font-family: var(--ov-mono);
  font-size: 7px;
  padding: 2px 6px;
  border: 1px solid;
  letter-spacing: 0.5px;
}

.ov-badge-live {
  color: var(--ov-green);
  border-color: rgba(0,255,0,0.3);
  background: rgba(0,255,0,0.08);
  animation: ov-pulse-badge 2s ease-in-out infinite;
}

@keyframes ov-pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ov-badge-cached {
  color: var(--ov-t3);
  border-color: var(--ov-border);
}

/* ═══════════════════════════════════════════════
   AI MACRO SUMMARY (Top Left)
   ═══════════════════════════════════════════════ */

.ov-macro-summary {
  grid-column: 1;
  grid-row: 1;
  min-height: 280px;
}

.ov-macro-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ov-macro-meta-left {
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
}

.ov-market-status {
  font-family: var(--ov-mono);
  font-size: 8px;
  padding: 2px 8px;
  border: 1px solid;
}

.ov-market-open {
  color: var(--ov-lime);
  border-color: rgba(211,251,3,0.3);
  background: rgba(211,251,3,0.06);
}

.ov-market-closed {
  color: var(--ov-coral);
  border-color: rgba(255,42,85,0.3);
  background: rgba(255,42,85,0.06);
}

.ov-summary-body {
  font-family: var(--ov-sans);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ov-t1);
  margin-bottom: 12px;
}

.ov-summary-body strong {
  color: var(--ov-lime);
  font-weight: 600;
  text-shadow: 0 0 6px rgba(211,251,3,0.15);
}

.ov-summary-body .ov-highlight-red {
  color: var(--ov-coral);
  font-weight: 600;
}

.ov-summary-body .ov-highlight-amber {
  color: var(--ov-amber);
  font-weight: 600;
}

.ov-macro-footer {
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
  padding-top: 6px;
  border-top: 1px solid var(--ov-border);
}

/* ═══════════════════════════════════════════════
   LIVE SIGNALS TABLE (Top Middle)
   ═══════════════════════════════════════════════ */

.ov-signals {
  grid-column: 2;
  grid-row: 1;
}

.ov-signals-head {
  display: grid;
  grid-template-columns: 1fr 60px 50px;
  gap: 4px;
  padding: 4px 0;
  margin-bottom: 2px;
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--ov-border);
}

.ov-signal-row {
  display: grid;
  grid-template-columns: 1fr 60px 50px;
  gap: 4px;
  padding: 6px 0;
  border-bottom: 1px solid var(--ov-border);
  align-items: center;
  transition: background 0.15s ease;
}

.ov-signal-row:hover {
  background: var(--ov-surface-2);
}

.ov-signal-asset {
  font-family: var(--ov-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ov-t1);
}

.ov-signal-bias {
  font-family: var(--ov-mono);
  font-size: 8px;
  font-weight: 700;
  padding: 2px 8px;
  text-align: center;
  letter-spacing: 0.5px;
}

.ov-bias-long {
  color: #000;
  background: var(--ov-lime);
}

.ov-bias-short {
  color: #fff;
  background: var(--ov-coral);
}

.ov-bias-neut {
  color: var(--ov-t2);
  background: var(--ov-surface-3);
}

.ov-signal-conf {
  font-family: var(--ov-mono);
  font-size: 10px;
  color: var(--ov-t2);
  text-align: right;
}

/* ═══════════════════════════════════════════════
   CORE MARKET DRIVERS — D3.js Container (Top Right)
   ═══════════════════════════════════════════════ */

.ov-drivers {
  grid-column: 3;
  grid-row: 1;
  min-height: 280px;
}

.ov-drivers-container {
  width: 100%;
  height: 220px;
  position: relative;
  overflow: hidden;
}

.ov-drivers-container svg {
  width: 100%;
  height: 100%;
}

/* D3 Force nodes */
.ov-driver-node {
  cursor: pointer;
  transition: opacity 0.2s;
}

.ov-driver-node:hover {
  opacity: 0.85;
}

.ov-driver-label {
  font-family: var(--ov-mono);
  font-size: 8px;
  fill: var(--ov-t1);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--ov-surface);
  stroke-width: 2px;
}

.ov-driver-impact {
  font-family: var(--ov-mono);
  font-size: 7px;
  fill: var(--ov-t3);
  text-anchor: middle;
  pointer-events: none;
}

.ov-drivers-legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 6px;
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
}

.ov-legend-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════
   SENTIMENT GAUGE (Middle Row)
   ═══════════════════════════════════════════════ */

.ov-sentiment-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--ov-border);
  border-top: 1px solid var(--ov-border);
}

.ov-sentiment-panel {
  background: var(--ov-surface);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.ov-sentiment-value {
  font-family: var(--ov-mono);
  font-size: 28px;
  font-weight: 800;
  min-width: 50px;
}

.ov-sentiment-label {
  font-family: var(--ov-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  letter-spacing: 1px;
}

.ov-sentiment-bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ov-sentiment-bar {
  width: 100%;
  height: 8px;
  background: linear-gradient(to right,
    var(--ov-coral) 0%,
    var(--ov-amber) 40%,
    var(--ov-lime) 100%
  );
  position: relative;
  overflow: visible;
}

.ov-sentiment-needle {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 16px;
  background: var(--ov-t1);
  transform: translateX(-50%);
  transition: left 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.ov-sentiment-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--ov-mono);
  font-size: 7px;
  color: var(--ov-t3);
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════
   ASSET HEATMAP GRID (Lower Middle)
   ═══════════════════════════════════════════════ */

.ov-heatmap-section {
  border-top: 1px solid var(--ov-border);
  background: var(--ov-surface);
  padding: 10px 14px 14px;
}

.ov-heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ov-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
}

.ov-hm-cell {
  background: var(--ov-surface-2);
  padding: 8px 6px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: background 0.3s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.ov-hm-cell:hover {
  border-color: var(--ov-border-2);
  z-index: 1;
}

.ov-hm-symbol {
  font-family: var(--ov-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--ov-t1);
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.ov-hm-change {
  font-family: var(--ov-mono);
  font-size: 12px;
  font-weight: 700;
}

.ov-hm-price {
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
  margin-top: 1px;
}

/* ── Heatmap Flash Effects ────────────────────────────── */
.ov-hm-cell.flash-green {
  background: rgba(0, 255, 0, 0.25) !important;
  box-shadow: inset 0 0 20px rgba(0,255,0,0.15), var(--ov-glow-green);
}

.ov-hm-cell.flash-red {
  background: rgba(255, 0, 0, 0.25) !important;
  box-shadow: inset 0 0 20px rgba(255,0,0,0.15), var(--ov-glow-red);
}

.ov-hm-cell.flash-green .ov-hm-change,
.ov-hm-cell.flash-green .ov-hm-symbol {
  text-shadow: var(--ov-glow-green);
}

.ov-hm-cell.flash-red .ov-hm-change,
.ov-hm-cell.flash-red .ov-hm-symbol {
  text-shadow: var(--ov-glow-red);
}

/* ─ Color Classes ─ */
.ov-up   { color: var(--ov-green); }
.ov-down { color: var(--ov-red); }
.ov-flat { color: var(--ov-t3); }

/* ═══════════════════════════════════════════════
   TICKER TABLE (Left side quick reference)
   ═══════════════════════════════════════════════ */

.ov-ticker-table {
  border-top: 1px solid var(--ov-border);
  padding-top: 8px;
  margin-top: 8px;
}

.ov-ticker-header {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr 80px;
  gap: 4px;
  font-family: var(--ov-mono);
  font-size: 8px;
  color: var(--ov-t3);
  letter-spacing: 1px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ov-border);
}

.ov-ticker-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr 80px;
  gap: 4px;
  padding: 3px 0;
  font-family: var(--ov-mono);
  font-size: 10px;
  border-bottom: 1px solid rgba(42,42,42,0.4);
  transition: background 0.15s;
  align-items: center;
}

.ov-ticker-row:hover {
  background: var(--ov-surface-2);
}

.ov-ticker-sym {
  color: var(--ov-t1);
  font-weight: 500;
}

.ov-ticker-price {
  color: var(--ov-t2);
  text-align: right;
}

.ov-ticker-chg {
  text-align: right;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════
   THE ABYSS — Bottom Deep Section
   ═══════════════════════════════════════════════ */

.ov-abyss {
  border-top: 2px solid var(--ov-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--ov-border);
}

/* ── Chart Container ─────────────────────────────────── */
.ov-chart-container {
  background: var(--ov-surface);
  height: 420px;
  padding: 12px 14px;
  position: relative;
}

.ov-chart-area {
  width: 100%;
  height: 340px;
  background: var(--ov-bg);
  border: 1px solid var(--ov-border);
  position: relative;
  overflow: hidden;
}

.ov-chart-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.ov-chart-placeholder-icon {
  font-size: 40px;
  color: var(--ov-border-2);
  margin-bottom: 8px;
}

.ov-chart-placeholder-text {
  font-family: var(--ov-mono);
  font-size: 10px;
  color: var(--ov-t3);
  letter-spacing: 1px;
}

.ov-chart-toolbar {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.ov-chart-btn {
  font-family: var(--ov-mono);
  font-size: 8px;
  padding: 4px 10px;
  background: var(--ov-surface-2);
  color: var(--ov-t2);
  border: 1px solid var(--ov-border);
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}

.ov-chart-btn:hover {
  background: var(--ov-surface-3);
  color: var(--ov-t1);
}

.ov-chart-btn.active {
  background: var(--ov-lime);
  color: #000;
  border-color: var(--ov-lime);
}

/* ── Order Flow Tape ─────────────────────────────────── */
.ov-orderflow {
  background: var(--ov-surface);
  height: 420px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.ov-flow-tape {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--ov-border-2) transparent;
}

.ov-flow-tape::-webkit-scrollbar {
  width: 4px;
}

.ov-flow-tape::-webkit-scrollbar-thumb {
  background: var(--ov-border-2);
}

.ov-flow-row {
  display: grid;
  grid-template-columns: 65px 50px 40px 55px 70px 55px 40px;
  gap: 4px;
  padding: 3px 0;
  font-family: var(--ov-mono);
  font-size: 9px;
  border-bottom: 1px solid rgba(42,42,42,0.3);
  animation: ov-flow-in 0.3s ease-out;
  align-items: center;
}

@keyframes ov-flow-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ov-flow-ts {
  color: var(--ov-t3);
  font-size: 8px;
}

.ov-flow-asset {
  color: var(--ov-t1);
  font-weight: 500;
}

.ov-flow-side {
  font-weight: 700;
  font-size: 8px;
  padding: 1px 4px;
  text-align: center;
}

.ov-flow-buy {
  color: var(--ov-green);
  background: rgba(0,255,0,0.08);
}

.ov-flow-sell {
  color: var(--ov-red);
  background: rgba(255,0,0,0.08);
}

.ov-flow-type {
  color: var(--ov-cyan);
  font-size: 7px;
  letter-spacing: 0.3px;
}

.ov-flow-size {
  color: var(--ov-t2);
  text-align: right;
}

.ov-flow-notional {
  color: var(--ov-amber);
  text-align: right;
  font-size: 8px;
}

.ov-flow-venue {
  color: var(--ov-t3);
  font-size: 7px;
  text-align: center;
}

/* Whale highlight */
.ov-flow-row.ov-whale {
  background: rgba(211,251,3,0.04);
  border-left: 2px solid var(--ov-lime);
}

.ov-flow-row.ov-whale .ov-flow-notional {
  color: var(--ov-lime);
  font-weight: 700;
  text-shadow: var(--ov-glow-lime);
}

/* ── Flow Stats Bar ─ */
.ov-flow-stats {
  display: flex;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--ov-border);
  margin-top: auto;
}

.ov-flow-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ov-flow-stat-label {
  font-family: var(--ov-mono);
  font-size: 7px;
  color: var(--ov-t3);
  letter-spacing: 0.5px;
}

.ov-flow-stat-value {
  font-family: var(--ov-mono);
  font-size: 12px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   WEBSOCKET STATUS INDICATOR
   ═══════════════════════════════════════════════ */

.ov-ws-status {
  position: fixed;
  bottom: 56px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ov-mono);
  font-size: 8px;
  padding: 4px 10px;
  background: var(--ov-surface);
  border: 1px solid var(--ov-border);
  z-index: 100;
  letter-spacing: 0.5px;
}

.ov-ws-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ov-green);
  animation: ov-pulse-dot 1.5s ease-in-out infinite;
}

.ov-ws-dot.disconnected {
  background: var(--ov-red);
  animation: none;
}

@keyframes ov-pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(0,255,0,0.6); }
  50% { opacity: 0.4; box-shadow: none; }
}

.ov-ws-label {
  color: var(--ov-t2);
}

.ov-ws-latency {
  color: var(--ov-t3);
}

/* ═══════════════════════════════════════════════
   D3 NODE PULSE ANIMATION
   ═══════════════════════════════════════════════ */

@keyframes ov-node-pulse {
  0%   { r: var(--base-r); opacity: 0.85; }
  50%  { r: calc(var(--base-r) + 3); opacity: 0.6; }
  100% { r: var(--base-r); opacity: 0.85; }
}

/* ═══════════════════════════════════════════════
   ANTI-FLICKER: Layout Shift Prevention (CLS < 0.05)
   Fixed min-heights prevent content jumps on data load/refresh
   ═══════════════════════════════════════════════ */

/* Signals panel — reserve space for ~8 signal rows */
#ov-signals-body {
  min-height: 280px;
}

/* Drivers panel — reserve space for ~8 driver bars */
#ov-drivers-body {
  min-height: 200px;
}

/* Heatmap grid — reserve space for cell grid */
.ov-heatmap-grid {
  min-height: 120px;
}

/* Indicators mount — reserve space for the full indicators section */
#ov-indicators-mount {
  min-height: 200px;
}

/* Radar chart — explicit dimensions prevent reflow */
.ov-ind-radar-chart {
  min-height: 280px;
}

/* Indicator table — lock layout */
.ov-ind-table {
  table-layout: fixed;
  width: 100%;
}

.ov-ind-table th,
.ov-ind-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI Analysis grid — reserve space */
.ov-ind-analysis {
  min-height: 120px;
}

/* ═══════════════════════════════════════════════
   ANTI-FLICKER: Smooth Value Transitions
   Animate data changes instead of component remount
   ═══════════════════════════════════════════════ */

/* Smooth color transitions on value cells */
.ov-hm-change,
.ov-ticker-chg,
.ov-ind-val-strong-pos,
.ov-ind-val-pos,
.ov-ind-val-neutral,
.ov-ind-val-neg,
.ov-ind-val-strong-neg {
  transition: color 0.3s ease, background-color 0.3s ease;
}

/* Sentiment needle smooth movement */
.ov-sentiment-needle {
  transition: left 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Driver bar smooth width changes */
#ov-drivers-body [id^="ov-drv-bar-"] {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Macro badge smooth updates */
.ov-panel-badge {
  transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE 
   ═══════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .ov-dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ov-drivers {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .ov-heatmap-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .ov-abyss {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .ov-dashboard-grid {
    grid-template-columns: 1fr;
  }
  .ov-heatmap-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .ov-flow-row {
    grid-template-columns: 55px 45px 35px 50px 60px 45px;
  }
}
