/**
 * Quansierge Design System - Color Tokens
 * ========================================
 * 
 * Centralized color system for light/dark theme support
 * All components should reference these CSS variables
 */

/* ========================================
   GLOBAL CONSTANTS (Theme-Independent)
   ======================================== */
:root {
    /* Spacing Scale */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.625rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;

    /* ---- Font Families ----
       Brand roles, not font preferences — change the var value to retheme all at once.
      --font-brand   : identity/logo moments
      --font-display : decorative section headers
       --font-ui      : interactive chrome — nav, buttons, labels, module titles
       --font-body    : dense readable text — table rows, tooltips, descriptions
       --font-data    : ALL financial/numeric values — must be monospace for alignment
    */
   --font-brand:   'Space Grotesk', 'Inter', system-ui, sans-serif;
   --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-ui:      'Inter', sans-serif;
   --font-body:    'Inter', sans-serif;
    --font-data:    'JetBrains Mono', monospace;  /* tabular/compact — fixed-width, column-safe */
    --font-number:  'JetBrains Mono', monospace;  /* large standalone KPIs — bold, tabular */

    /* ---- Type Scale (base: 1rem = 16px browser default) ----
       Named by role, not by size — use these instead of raw rem values.
       Floor: --text-micro. Prefer semantic --type-* roles in product CSS.
    */
    --text-micro: 0.5rem;    /* 8px — absolute floor (chart ticks, dense table heads) */
    --text-3xs:   0.5625rem; /* 9px — eyebrows, dense meta, nav group labels */
    --text-2xs:   0.625rem;  /* 10px — kickers, badges, segment labels */
    --text-xs:    0.6875rem; /* 11px — rail titles, KPI meta, footer nav */
    --text-sm:    0.75rem;   /* 12px — page meta, primary nav, body meta */
    --text-prose: 0.8125rem; /* 13px — modal body, dense readable copy */
    --text-base:  0.875rem;  /* 14px — emphasized body / module titles */
    --text-md:    1rem;      /* 16px — modal titles, emphasized UI */
    --text-lg:    1.125rem;  /* 18px — page titles, brand mark */
    --text-xl:    1.25rem;   /* 20px — section heroes */
    --text-2xl:   1.5rem;    /* 24px — large standalone values */
    --text-3xl:   1.75rem;   /* 28px — brand number size */
    --text-hero:  2.5rem;    /* 40px — display heroes */

    /* ---- Semantic typography roles (prefer these in product CSS) ---- */
    --type-page-title: var(--text-lg);
    --type-page-meta:  var(--text-sm);
    --type-brand-mark: var(--text-lg);
    --type-nav-item:   var(--text-sm);
    --type-nav-label:  var(--text-3xs);
    --type-nav-footer: var(--text-xs);
    --type-rail-title: var(--text-xs);
    --type-rail-meta:  var(--text-3xs);
    --type-kicker:     var(--text-2xs);
    --type-kpi-meta:   var(--text-3xs);
    --type-seg:        var(--text-xs);
    --type-micro:      var(--text-micro);
}

/* ========================================
   DARK THEME (Default)
   ======================================== */
:root,
[data-theme="dark"] {
    color-scheme: dark;

    /* Base Backgrounds — deep charcoal with cool undertone */
    --bg-primary: #0e131a;
    --bg-secondary: #161d28;
    --bg-tertiary: #1e2836;
    --bg-module: color-mix(in srgb, var(--bg-secondary) 92%, var(--bg-primary));
    --bg-card: rgba(20, 27, 38, 0.94);
    --bg-elevated: rgba(30, 40, 54, 0.98);
    --bg-hover: rgba(0, 217, 255, 0.12);
    --bg-selected: rgba(0, 217, 255, 0.20);
    --overlay-backdrop: rgba(0, 0, 0, 0.52);
    --overlay-backdrop-strong: rgba(0, 0, 0, 0.78);
    --tooltip-bg: rgba(16, 22, 32, 0.96);
    --tooltip-text: #f3f7fb;
    --tooltip-border: rgba(0, 217, 255, 0.28);
    --shadow-backdrop: rgba(0, 0, 0, 0.58);

    /* Page atmosphere (radial washes over --bg-primary) */
    --bg-atmosphere-1: rgba(0, 217, 255, 0.11);
    --bg-atmosphere-2: rgba(255, 170, 0, 0.05);
    --bg-atmosphere-3: rgba(0, 120, 160, 0.08);

    /* Text Colors */
    --text-primary: #f3f7fb;
    --text-secondary: #b0becc;
    --text-muted: #8f9eae;
    --text-inverse: #0e131a;

    /* Border Colors — cool slate with cyan focus */
    --border-primary: rgba(88, 102, 120, 0.72);
    --border-secondary: rgba(88, 102, 120, 0.45);
    --border-hover: rgba(0, 217, 255, 0.42);
    --border-active: rgba(0, 217, 255, 0.58);
    --border-focus: rgba(0, 217, 255, 0.78);

    /* Brand Colors — Helix cyan leads chrome + identity */
    --accent-primary: #00d9ff;
    --accent-secondary: #3de0ff;
    --accent-tertiary: #7aebff;
    --brand-glow: 0 0 28px rgba(0, 217, 255, 0.22);

    /* Semantic Colors — Success (mint, on-palette with cyan) */
    --success-50: rgba(62, 207, 154, 0.1);
    --success-100: rgba(62, 207, 154, 0.2);
    --success-500: #3ecf9a;
    --success-600: #2fb885;
    --success-700: #249e71;
    --success-text: #3ecf9a;
    --success-bg: rgba(62, 207, 154, 0.18);
    --success-border: rgba(62, 207, 154, 0.42);

    /* Semantic Colors — Error/Danger (coral) */
    --error-50: rgba(255, 107, 122, 0.1);
    --error-100: rgba(255, 107, 122, 0.2);
    --error-500: #ff6b7a;
    --error-600: #e85a68;
    --error-700: #cc4a56;
    --error-text: #ff6b7a;
    --error-bg: rgba(255, 107, 122, 0.12);
    --error-border: rgba(255, 107, 122, 0.35);

    /* Semantic Colors — Warning (amber) */
    --warning-50: rgba(240, 180, 41, 0.1);
    --warning-100: rgba(240, 180, 41, 0.2);
    --warning-500: #f0b429;
    --warning-600: #d9a01f;
    --warning-700: #b8860b;
    --warning-text: #f0b429;
    --warning-bg: rgba(240, 180, 41, 0.12);
    --warning-border: rgba(240, 180, 41, 0.35);

    /* Semantic Colors — Info (Helix-adjacent cyan-blue) */
    --info-50: rgba(0, 196, 230, 0.1);
    --info-100: rgba(0, 196, 230, 0.2);
    --info-500: #00c4e6;
    --info-600: #00a8c7;
    --info-700: #008aa5;
    --info-text: #00c4e6;
    --info-bg: rgba(0, 196, 230, 0.12);
    --info-border: rgba(0, 196, 230, 0.35);

    /* Chart Colors — Helix / mint / steel */
    --chart-grid: rgba(72, 84, 100, 0.34);
    --chart-border: rgba(154, 168, 183, 0.34);
    --chart-text: #9aa8b7;
    --chart-line-1: #00d9ff;
    --chart-line-2: #3ecf9a;
    --chart-line-3: #8fa3b8;
    --chart-line-4: #ffaa00;
    --chart-account-a1: #00d9ff;
    --chart-account-a2: #3de0ff;
    --chart-account-backtest: #a0aec0;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.34);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 6px 14px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.36);
    --shadow-xl: 0 18px 36px rgba(0, 0, 0, 0.42);
    --shadow-glow: 0 0 22px rgba(0, 217, 255, 0.14);

    /* Segmented controls + soft surfaces */
    --hx-seg-track-bg: rgba(0, 0, 0, 0.32);
    --hx-seg-track-border: rgba(255, 255, 255, 0.06);
    --hx-seg-inset: inset 0 1px 2px rgba(0, 0, 0, 0.28);
    --hx-seg-active-shine: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    --surface-sunken: rgba(13, 17, 23, 0.28);
    --surface-muted: rgba(255, 255, 255, 0.03);
    --surface-hairline: rgba(255, 255, 255, 0.06);
    --heat-cell-base: rgba(13, 17, 23, 0.28);
    --marker-ring: rgba(13, 17, 23, 0.9);
    --on-heat-text: rgba(255, 255, 255, 0.92);

    /* Trading-Specific Colors */
    --trade-long: #3ecf9a;
    --trade-short: #ff6b7a;
    --trade-neutral: #6e7681;
    --position-bg-long: rgba(62, 207, 154, 0.12);
    --position-bg-short: rgba(255, 107, 122, 0.12);
    --position-border-long: rgba(62, 207, 154, 0.35);
    --position-border-short: rgba(255, 107, 122, 0.35);

    /* Strategy Colors */
    --strategy-helix: #00d9ff;
    --strategy-helix-bg: rgba(0, 217, 255, 0.18);
    --strategy-helix-border: rgba(0, 217, 255, 0.45);
}

/* ========================================
   LIGHT THEME
   Cool paper surfaces, Helix cyan kept for identity
   ======================================== */
[data-theme="light"] {
    color-scheme: light;

    --bg-primary: #f3f6fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8edf4;
    --bg-module: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.96);
    --bg-elevated: #ffffff;
    --bg-hover: rgba(0, 132, 158, 0.08);
    --bg-selected: rgba(0, 132, 158, 0.14);
    --overlay-backdrop: rgba(18, 28, 42, 0.28);
    --overlay-backdrop-strong: rgba(18, 28, 42, 0.48);
    --tooltip-bg: rgba(255, 255, 255, 0.98);
    --tooltip-text: #142033;
    --tooltip-border: rgba(0, 132, 158, 0.28);
    --shadow-backdrop: rgba(18, 28, 42, 0.28);

    --bg-atmosphere-1: rgba(0, 145, 176, 0.08);
    --bg-atmosphere-2: rgba(255, 160, 40, 0.05);
    --bg-atmosphere-3: rgba(40, 90, 140, 0.05);

    --text-primary: #121c2c;
    --text-secondary: #31465c;
    --text-muted: #4a5e74;
    --text-inverse: #f3f7fb;

    --border-primary: rgba(42, 62, 86, 0.34);
    --border-secondary: rgba(42, 62, 86, 0.22);
    --border-hover: rgba(0, 132, 158, 0.42);
    --border-active: rgba(0, 132, 158, 0.55);
    --border-focus: rgba(0, 132, 158, 0.72);

    /* Slightly deeper cyan for contrast on paper */
    --accent-primary: #0091b0;
    --accent-secondary: #00a8c7;
    --accent-tertiary: #14bdd6;
    --brand-glow: none;

    --success-50: rgba(13, 159, 110, 0.08);
    --success-100: rgba(13, 159, 110, 0.16);
    --success-500: #0d9f6e;
    --success-600: #0b8a5f;
    --success-700: #097350;
    --success-text: #0d9f6e;
    --success-bg: rgba(13, 159, 110, 0.12);
    --success-border: rgba(13, 159, 110, 0.32);
    --gain-fill: rgba(13, 159, 110, 0.72);
    --loss-fill: rgba(216, 64, 80, 0.72);

    --error-50: rgba(216, 64, 80, 0.08);
    --error-100: rgba(216, 64, 80, 0.16);
    --error-500: #d84050;
    --error-600: #c23444;
    --error-700: #a82b39;
    --error-text: #c23444;
    --error-bg: rgba(216, 64, 80, 0.10);
    --error-border: rgba(216, 64, 80, 0.30);

    --warning-50: rgba(184, 122, 12, 0.08);
    --warning-100: rgba(184, 122, 12, 0.16);
    --warning-500: #c98a0a;
    --warning-600: #b07809;
    --warning-700: #946508;
    --warning-text: #a67409;
    --warning-bg: rgba(184, 122, 12, 0.10);
    --warning-border: rgba(184, 122, 12, 0.30);

    --info-50: rgba(0, 132, 158, 0.08);
    --info-100: rgba(0, 132, 158, 0.16);
    --info-500: #0091b0;
    --info-600: #007e99;
    --info-700: #006a82;
    --info-text: #007e99;
    --info-bg: rgba(0, 132, 158, 0.10);
    --info-border: rgba(0, 132, 158, 0.30);

    --chart-grid: rgba(42, 62, 86, 0.20);
    --chart-border: rgba(42, 62, 86, 0.32);
    --chart-text: #4a5e74;
    --chart-line-1: #3d5f82;
    --chart-line-2: #5c7d9e;
    --chart-line-3: #7a8fa6;
    --chart-line-4: #d4890a;
    --chart-account-a1: #3d5f82;
    --chart-account-a2: #5c7d9e;
    --chart-account-backtest: #7a8fa6;

    --shadow-xs: 0 1px 2px rgba(18, 28, 42, 0.04);
    --shadow-sm: 0 2px 6px rgba(18, 28, 42, 0.06);
    --shadow-md: 0 6px 16px rgba(18, 28, 42, 0.08);
    --shadow-lg: 0 12px 28px rgba(18, 28, 42, 0.10);
    --shadow-xl: 0 20px 40px rgba(18, 28, 42, 0.12);
    --shadow-glow: 0 0 18px rgba(0, 145, 176, 0.10);

    --hx-seg-track-bg: rgba(18, 28, 42, 0.06);
    --hx-seg-track-border: rgba(18, 28, 42, 0.08);
    --hx-seg-inset: inset 0 1px 2px rgba(18, 28, 42, 0.05);
    --hx-seg-active-shine: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --surface-sunken: rgba(18, 28, 42, 0.055);
    --surface-muted: rgba(18, 28, 42, 0.06);
    --surface-hairline: rgba(18, 28, 42, 0.12);
    --heat-cell-base: rgba(230, 236, 244, 0.92);
    --marker-ring: rgba(255, 255, 255, 0.92);
    --on-heat-text: rgba(20, 32, 51, 0.92);

    --trade-long: #0d9f6e;
    --trade-short: #d84050;
    --trade-neutral: #6b7f96;
    --position-bg-long: rgba(13, 159, 110, 0.10);
    --position-bg-short: rgba(216, 64, 80, 0.10);
    --position-border-long: rgba(13, 159, 110, 0.28);
    --position-border-short: rgba(216, 64, 80, 0.28);

    --strategy-helix: #0091b0;
    --strategy-helix-bg: rgba(0, 145, 176, 0.10);
    --strategy-helix-border: rgba(0, 145, 176, 0.32);
}

/* ========================================
   LEGACY COMPATIBILITY
   ======================================== */
:root {
    /* Old variable names for backward compatibility */
    --card-bg: var(--bg-card);
    --card-border: var(--border-primary);
    --card-hover-border: var(--border-hover);
    --accent-color: var(--accent-primary);
    --transition-standard: var(--transition-slow);
    --border-radius-sm: var(--radius-sm);
    --border-radius-md: var(--radius-md);
    --border-radius-lg: var(--radius-lg);
    --spacing-sm: var(--spacing-sm);
    --spacing-md: var(--spacing-md);
    --spacing-lg: var(--spacing-lg);
    --spacing-xl: var(--spacing-xl);
}



/* ========================================
   SHARED STATES & MODAL PRIMITIVES
   ======================================== */


.positive { 
    color: var(--success-text); 
}

.negative { 
    color: var(--error-text); 
}

.dashboard-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    padding: clamp(0.75rem, 3vh, 1.25rem);
    background: var(--shadow-backdrop);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
}

.dashboard-modal.is-open {
    display: flex;
}

.dashboard-modal__panel {
    width: min(96vw, 560px);
    max-height: min(92vh, 720px);
    margin: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: 0.625rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.dashboard-modal__panel--md {
    width: min(96vw, 560px);
    max-height: min(92vh, 640px);
}

.dashboard-modal__panel--lg {
    width: min(96vw, 680px);
    max-height: min(92vh, 780px);
}

.dashboard-modal__panel--xl {
    width: min(96vw, 960px);
    max-height: min(92vh, 720px);
}

.dashboard-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.dashboard-modal__heading h2 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
}

.dashboard-modal__subtitle {
    margin: 0.25rem 0 0;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.45;
    max-width: 42rem;
}

.dashboard-modal__close {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xl);
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.dashboard-modal__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dashboard-modal__body {
    flex: 1;
    min-height: 0;
    padding: 1rem 1.125rem;
    overflow-y: auto;
    font-family: var(--font-ui);
    font-size: var(--text-prose);
    color: var(--text-primary);
}

.dashboard-modal__footer {
    padding: 0.875rem 1.125rem;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.dashboard-modal__footer-label {
    font-size: var(--text-prose);
    font-weight: 500;
    color: var(--text-primary);
}

.dashboard-modal__footer-value {
    font-family: var(--font-data);
    font-size: var(--text-md);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dashboard-modal__empty,
.dashboard-modal__loading {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: var(--text-prose);
}

.dashboard-modal__meta {
    margin-bottom: 0.75rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.dashboard-modal__section-label {
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.no-data {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-style: italic;
    line-height: 1.5;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: var(--text-hero);
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-state p {
    font-size: var(--text-base);
    margin: 0;
}
