/* ═══════════════════════════════════════════════
   SwingTrader AI — Design System (main.css)
   ═══════════════════════════════════════════════ */

/* ── 1. CSS Custom Properties ── */
:root {
  /* Backgrounds */
  --bg-base:        #07061A;
  --bg-surface:     #0E0B2E;
  --bg-card:        rgba(255,255,255,0.055);
  --bg-card-hover:  rgba(255,255,255,0.09);
  --bg-input:       rgba(255,255,255,0.07);
  --bg-sidebar:     #0A0820;

  /* Brand Gradients */
  --grad-primary:   linear-gradient(135deg, #2563EB, #60A5FA);
  --grad-blue:      linear-gradient(135deg, #2563EB, #06B6D4);
  --grad-green:     linear-gradient(135deg, #059669, #10B981);
  --grad-amber:     linear-gradient(135deg, #D97706, #F59E0B);
  --grad-rose:      linear-gradient(135deg, #E11D48, #F43F5E);
  --grad-cyan:      linear-gradient(135deg, #0891B2, #38BDF8);
  --grad-orange:    linear-gradient(135deg, #EA580C, #FB923C);
  --grad-indigo:    linear-gradient(135deg, #2563EB, #60A5FA);
  --grad-ticker:    linear-gradient(90deg,  #2563EB, #60A5FA, #2563EB, #06B6D4);

  /* Semantic Colors */
  --clr-bull:     #10B981;
  --clr-bull-dim: rgba(16,185,129,0.15);
  --clr-bear:     #F43F5E;
  --clr-bear-dim: rgba(244,63,94,0.15);
  --clr-warn:     #F59E0B;
  --clr-warn-dim: rgba(245,158,11,0.15);
  --clr-info:     #38BDF8;
  --clr-info-dim: rgba(56,189,248,0.15);
  --clr-indigo:   #3B82F6;
  --clr-cyan:     #22D3EE;

  /* Text */
  --txt-primary:   #F1F5F9;
  --txt-secondary: #94A3B8;
  --txt-muted:     #4B5563;
  --txt-accent:    #93C5FD;

  /* Borders */
  --border-subtle:  rgba(255,255,255,0.08);
  --border-medium:  rgba(255,255,255,0.14);
  --border-accent:  rgba(37,99,235,0.5);

  /* Shadows */
  --shadow-card:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow-indigo: 0 0 30px rgba(37,99,235,0.3);
  --shadow-glow-green:  0 0 20px rgba(16,185,129,0.25);
  --shadow-glow-rose:   0 0 20px rgba(244,63,94,0.25);

  /* Spacing */
  --sp-xs:  4px;  --sp-sm: 8px;  --sp-md: 16px;
  --sp-lg: 24px;  --sp-xl: 32px; --sp-2xl: 48px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-full: 9999px;

  /* Typography */
  --font-body: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --sidebar-w: 240px;
  --ticker-h:  40px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--txt-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Subtle radial glow on bg */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(37,99,235,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(6,182,212,0.06) 0%, transparent 60%);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(37,99,235,0.5); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #2563EB; }

/* ── 3. Ticker Bar ── */
.ticker-wrap {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--ticker-h);
  background: linear-gradient(90deg, #0A0820, #0E0B2E);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; overflow: hidden;
}

.ticker-label-badge {
  flex-shrink: 0;
  background: var(--grad-primary);
  color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  padding: 3px 12px;
  margin-left: var(--sp-md);
  border-radius: var(--r-full);
  white-space: nowrap;
}

.ticker-track {
  flex: 1; overflow: hidden; position: relative;
  mask-image: linear-gradient(90deg, transparent 0%, black 5%, black 95%, transparent 100%);
}

.ticker-inner {
  display: flex; align-items: center; gap: 0;
  animation: tickerScroll 60s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 20px;
  font-family: var(--font-mono); font-size: 12px;
  border-right: 1px solid var(--border-subtle);
}
.ticker-sym { color: var(--txt-primary); font-weight: 600; }
.ticker-price { color: var(--txt-secondary); }
.ticker-chg.up   { color: var(--clr-bull); }
.ticker-chg.down { color: var(--clr-bear); }

@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── 4. App Shell Layout ── */
.app-shell {
  display: flex;
  height: 100vh;
  padding-top: var(--ticker-h);
  position: relative; z-index: 1;
}

/* ── 5. Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  padding: var(--sp-lg) 0 var(--sp-md);
  overflow-y: auto; overflow-x: hidden;
  position: relative;
}

/* Sidebar accent stripe */
.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; bottom: 0; width: 2px;
  background: var(--grad-primary);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--sp-md);
}

.brand-glyph {
  width: 36px; height: 36px;
  background: var(--grad-primary);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow-indigo);
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px; font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -0.3px;
}

.brand-ai {
  background: var(--grad-blue);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-sub {
  font-size: 9px; color: var(--txt-muted);
  letter-spacing: 0.8px; text-transform: uppercase; margin-top: 1px;
}

/* Nav Groups */
.nav-group { margin-bottom: var(--sp-sm); }

.nav-group-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 2px; color: var(--txt-muted);
  padding: var(--sp-sm) var(--sp-lg) var(--sp-xs);
  text-transform: uppercase;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--sp-md);
  margin: 1px 8px;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  color: var(--txt-secondary);
  transition: var(--transition);
  position: relative; cursor: pointer;
}

.nav-link:hover {
  background: var(--bg-card);
  color: var(--txt-primary);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.2), rgba(96,165,250,0.15));
  color: var(--txt-primary);
  border: 1px solid rgba(37,99,235,0.3);
}
.nav-link.active .nav-ico { filter: none; }

.nav-ico { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-txt { flex: 1; }

.badge-live {
  font-size: 8px; font-weight: 700; letter-spacing: 1px;
  background: var(--clr-bull); color: #000;
  padding: 2px 6px; border-radius: var(--r-full);
  animation: pulse-green 2s infinite;
}

.badge-ai {
  font-size: 8px; font-weight: 700;
  background: var(--grad-primary);
  color: #fff; padding: 2px 7px;
  border-radius: var(--r-full);
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: var(--sp-md);
  border-top: 1px solid var(--border-subtle);
}

.mkt-status-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-card);
  padding: 6px 12px; border-radius: var(--r-full);
  margin-bottom: var(--sp-sm);
}

.mkt-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--clr-warn);
}
.mkt-dot.open   { background: var(--clr-bull); animation: pulse-green 1.5s infinite; }
.mkt-dot.closed { background: var(--clr-bear); }

.clock {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--txt-muted); text-align: center;
}

/* ── 6. Main Content ── */
.content-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-base);
  position: relative;
}

.page { display: none; padding: var(--sp-xl); animation: fadeIn 0.3s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 7. Modal ── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: block; }

.modal-wrap {
  display: none; position: fixed; z-index: 2001;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 90%; max-width: 640px;
  background: #13102E;
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
  padding: var(--sp-xl);
  box-shadow: 0 25px 80px rgba(0,0,0,0.7), var(--shadow-glow-indigo);
}
.modal-wrap.open { display: block; animation: modalIn 0.3s ease; }

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -52%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ── 8. Typography Utilities ── */
.text-bull   { color: var(--clr-bull); }
.text-bear   { color: var(--clr-bear); }
.text-warn   { color: var(--clr-warn); }
.text-info   { color: var(--clr-info); }
.text-muted  { color: var(--txt-muted); }
.text-mono   { font-family: var(--font-mono); }
.text-sm     { font-size: 11px; }
.text-xs     { font-size: 10px; }
.text-lg     { font-size: 16px; }
.text-xl     { font-size: 20px; }
.text-2xl    { font-size: 24px; }
.text-3xl    { font-size: 30px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.grad-text-primary {
  background: var(--grad-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.grad-text-blue {
  background: var(--grad-blue);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.grad-text-green {
  background: var(--grad-green);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ── 9. Layout Utilities ── */
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.gap-lg { gap: var(--sp-lg); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-md); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-md); }

/* Responsive grid */
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 900px)  { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { width: 60px; }
  .brand-name, .brand-sub, .nav-txt, .nav-group-label, .badge-live, .badge-ai { display: none; }
  .page { padding: var(--sp-md); }
}

/* Misc utils */
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); }
.mb-md { margin-bottom: var(--sp-md); }
.mb-lg { margin-bottom: var(--sp-lg); }
.p-md { padding: var(--sp-md); }
.p-lg { padding: var(--sp-lg); }
