/**
 * NexTrade — Core Design System (Institutional Matte)
 * * AESTHETIC: Deep Obsidian, Matte Surfaces, Electric Blue Accents.
 * * ARCHITECTURE: 4px Grid, System Typography, GPU-Accelerated Layers.
 * * TARGET: "Senior" Tailwind-grade precision.
 */

/* ============================================
   1. DESIGN TOKENS (ROOT)
   ============================================ */

:root {
  /* ----------------------------------
     COLOR PALETTE: "The Obsidian Theme"
     ---------------------------------- */
  
  /* Backgrounds (Cooler, deeper blacks) */
  --color-background: #0B0E11;       /* Deepest obsidian */
  --color-surface: #151921;          /* Matte card surface */
  --color-surface-elevated: #1E232F; /* Modals / Dropdowns */
  --color-surface-sunken: #050709;   /* Inputs / Wells */
  
  /* Borders (Subtle, glassy) */
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.15);
  --color-border-active: rgba(255, 255, 255, 0.25);
  
  /* Primary Brand (Electric Blue) */
  --color-primary: #3B82F6;          /* Vibrant, trustworthy blue */
  --color-primary-hover: #2563EB;    /* Deepening on interaction */
  --color-primary-active: #1D4ED8;
  --color-primary-glow: rgba(59, 130, 246, 0.15); /* For blurred effects */
  
  /* Text & Content */
  --color-text-primary: #F8FAFC;     /* Pure white/blue-white */
  --color-text-secondary: #94A3B8;   /* Cool gray, high readability */
  --color-text-tertiary: #64748B;    /* Deep gray for meta data */
  --color-text-inverse: #0B0E11;     /* For text on white buttons */
  
  /* Functional Status Colors */
  /* Semantic Status Colors — four roles, no others:
     success/profit = green | caution/pending = amber | destructive/fail = red | action = blue (primary above) */
  --color-success: #10B981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-success-border: rgba(16, 185, 129, 0.22);
  --color-warning: #F59E0B;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.22);
  --color-danger: #EF4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-danger-border: rgba(239, 68, 68, 0.22);

  /* ----------------------------------
     TYPOGRAPHY: "System Precision"
     ---------------------------------- */
  
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'Roboto Mono', 'Courier New', monospace;
  
  /* Scale (Major Third based) */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 2rem;      /* 32px */
  --text-4xl: 2.5rem;    /* 40px */
  
  /* Weights (Modern / Lighter) */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  
  /* Tracking */
  --tracking-tighter: -0.04em;
  --tracking-tight:   -0.02em;
  --tracking-normal:   0em;
  --tracking-wide:     0.03em;   /* Subtle: caps labels, button text */
  --tracking-widest:   0.08em;   /* Reserved: badge/tag micro-text only */

  /* ----------------------------------
     SPACING: 4px Grid System
     ---------------------------------- */
     
  --space-0: 0px;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* ----------------------------------
     SHAPES & DEPTH
     ---------------------------------- */
     
  --radius-sm:   8px;   /* Chips, badges, small inputs */
  --radius-base: 12px;  /* Buttons, inputs, small cards */
  --radius-lg:   16px;  /* Standard cards */
  --radius-xl:   22px;  /* Modals, hero card bottom */
  --radius-pill: 9999px;

  /* Shadows (Atmospheric) */
  --shadow-sm:   0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.45), 0 2px 4px -1px rgba(0, 0, 0, 0.25);
  --shadow-md:   0 6px 16px -4px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.30);
  --shadow-lg:   0 12px 24px -6px rgba(0, 0, 0, 0.60), 0 4px 8px -2px rgba(0, 0, 0, 0.35);
  --shadow-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.07); /* Top edge light */

  /* ── MISSING TOKENS referenced in JS but not declared ── */
  --color-text-disabled: #475569;   /* For disabled buttons / inputs */

  /* Animations — deceleration curve for enters, acceleration for exits */
  --transition-fast:   150ms cubic-bezier(0.25, 0, 0.15, 1);
  --transition-base:   240ms cubic-bezier(0.25, 0, 0.15, 1);
  --transition-slow:   380ms cubic-bezier(0.25, 0, 0.15, 1);
  --transition-bounce: 400ms cubic-bezier(0.34, 1.4, 0.64, 1);
  
  /* Layout Constaints */
  --container-max-width: 1200px;
  --navbar-height: 64px;
}

/* ============================================
   2. RESET & BASE
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-background);
  /* Scroll logic handled in layout.css, this is a fallback */
  overflow-x: hidden;
  min-height: 100vh;
}

/* ============================================
   3. TYPOGRAPHY SYSTEM
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: var(--text-4xl); letter-spacing: var(--tracking-tighter); }
h2 { font-size: var(--text-3xl); letter-spacing: var(--tracking-tighter); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: var(--weight-medium); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--weight-medium);
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

/* Specialized: Financial Data */
.financial-data, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

/* ============================================
   4. COMPONENT BASES
   ============================================ */

/* Buttons (Base Reset) */
button {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: none;
  background: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Forms (Matte Style) */
input, textarea, select {
  font-family: var(--font-ui);
  font-size: var(--text-base); /* Prevents zoom on mobile */
  color: var(--color-text-primary);
  background-color: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-3) var(--space-4);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

input::placeholder {
  color: var(--color-text-tertiary);
}

/* ============================================
   5. UTILITIES (Tailwind-inspired)
   ============================================ */

/* Text Helpers */
.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

/* Flexbox Helpers */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-row     { flex-direction: row; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.justify-start  { justify-content: flex-start; }

.flex-1 { flex: 1; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Spacing (Margins & Padding) */
.m-0  { margin: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }

/* Sizing & Layout */
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.block  { display: block; }
.relative { position: relative; }
.absolute { position: absolute; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

/* ============================================
   6. SCROLLBARS & UI POLISH
   ============================================ */

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* Selection */
::selection {
  background: rgba(59, 130, 246, 0.3); /* Primary glow */
  color: #fff;
}

/* Focus Visible (Accessibility) */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
