/* ==========================================================================
   Market Forecast Simulator — Styles
   Dark professional dashboard theme (Bloomberg-esque).
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg-root:       #0b0f19;
  --bg-surface:    #111827;
  --bg-elevated:   #1a2332;
  --bg-overlay:    #1f2a3a;
  --bg-input:      #0f172a;

  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.10);
  --border-mid:    rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.24);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;
  --text-dim:       #64748b;

  /* Accent */
  --accent:         #3b82f6;
  --accent-soft:    rgba(59, 130, 246, 0.15);
  --accent-glow:    rgba(59, 130, 246, 0.30);

  /* Semantic */
  --green:          #10b981;
  --green-soft:     rgba(16, 185, 129, 0.12);
  --red:            #ef4444;
  --red-soft:       rgba(239, 68, 68, 0.12);
  --amber:          #f59e0b;
  --amber-soft:     rgba(245, 158, 11, 0.12);

  /* Layout */
  --sidebar-w:      340px;
  --nav-h:          56px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;

  /* Typography */
  --font-sans:      'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Shadows */
  --shadow-card:    0 1px 2px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
  --shadow-elevated: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-glow:    0 0 20px rgba(59,130,246,0.08);

  /* Transitions */
  --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar               { width: 6px; height: 6px; }
::-webkit-scrollbar-track         { background: transparent; }
::-webkit-scrollbar-thumb         { background: rgba(148,163,184,0.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover   { background: rgba(148,163,184,0.30); }

/* --------------------------------------------------------------------------
   Top Nav
   -------------------------------------------------------------------------- */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-logo {
  width: 32px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
}

.nav-title {
  display: flex;
  flex-direction: column;
}

.nav-title-main {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.nav-title-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s var(--ease-out);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #2563eb;
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-mid);
}
.btn-ghost:hover {
  background: rgba(148,163,184,0.08);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Main Layout
   -------------------------------------------------------------------------- */
.main-layout {
  display: flex;
  height: calc(100vh - var(--nav-h));
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-header {
  margin-bottom: 6px;
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Preset grid */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.preset-btn:hover {
  border-color: var(--border-mid);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(59,130,246,0.12);
}

.preset-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.preset-btn:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* Param list */
.param-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.param-group {
  padding: 10px 0;
}

.param-group + .param-group {
  border-top: 1px solid var(--border-subtle);
}

.param-group-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.param-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.param-label-row label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.param-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
}

.param-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-root);
  box-shadow: 0 0 0 2px var(--accent-soft);
  cursor: pointer;
  transition: box-shadow 0.15s var(--ease-out);
}

.param-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.param-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Content Area
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

/* --------------------------------------------------------------------------
   Spinner
   -------------------------------------------------------------------------- */
.spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11,15,25,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border-radius: var(--radius-lg);
}

.spinner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Stats Row
   -------------------------------------------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.stat-card:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow-card);
}

.stat-card.up    { border-left: 3px solid var(--green); }
.stat-card.down  { border-left: 3px solid var(--red); }
.stat-card.neutral { border-left: 3px solid var(--accent); }

.stat-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Charts Section
   -------------------------------------------------------------------------- */
.charts-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chart-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 4px;
  border: 1px solid var(--border-subtle);
  border-bottom: none;
}

.tab-btn {
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(148,163,184,0.06);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tab-panels {
  border: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--bg-surface);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.chart-card {
  padding: 0;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 10px;
}

.chart-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-badge {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.chart-wrap {
  padding: 0 16px 16px;
  position: relative;
}

.chart-wrap.tall {
  height: 420px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --------------------------------------------------------------------------
   Table
   -------------------------------------------------------------------------- */
.table-section {
  /* sits in content flow */
}

.table-wrap {
  overflow-x: auto;
  padding: 0 20px 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tbody tr:hover td {
  background: rgba(148,163,184,0.03);
}

.data-table .num {
  font-family: var(--font-mono);
  text-align: right;
  font-size: 12.5px;
}

.data-table .positive { color: var(--green); }
.data-table .negative { color: var(--red); }

.scenario-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   Executive Summary
   -------------------------------------------------------------------------- */
.summary-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.summary-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-date {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.summary-body {
  padding: 20px 24px 24px;
}

.summary-lede {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.summary-lede strong {
  color: var(--text-primary);
}

.insights-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.insights-box h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.insights-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-item {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.summary-actions {
  padding-top: 4px;
}

.summary-actions h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.summary-actions ol {
  list-style: none;
  counter-reset: action-counter;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-actions ol li {
  counter-increment: action-counter;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 28px;
  position: relative;
}

.summary-actions ol li::before {
  content: counter(action-counter);
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.content-footer {
  padding-top: 8px;
  text-align: center;
}

.content-footer p {
  font-size: 11px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 280px; }
  .stats-row { grid-template-columns: 1fr; }
  .chart-tabs { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .main-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-width: 0;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .chart-wrap.tall { height: 300px; }
  .nav-actions { gap: 6px; }
  .btn { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 32px; }
  .nav-title-sub { display: none; }
}
