/* ===================================
   AlgoTrader - Premium Trading Terminal UI
   Modern • Complex • Compact • Professional
   Bloomberg Terminal meets Modern Fintech
   =================================== */

/* Import fonts - Premium typography stack */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ===================================
   CSS Variables - Premium Dark Terminal
   =================================== */
:root {
    /* ═══════════════════════════════════
       BRAND COLORS - Cyan/Teal Focus
       ═══════════════════════════════════ */
    --primary: #00e5cc;
    --primary-hover: #00c9b3;
    --primary-active: #00b3a1;
    --primary-glow: rgba(0, 229, 204, 0.2);
    --primary-glow-strong: rgba(0, 229, 204, 0.35);
    --primary-border: rgba(0, 229, 204, 0.4);
    --primary-soft: rgba(0, 229, 204, 0.08);
    
    /* Secondary - Electric Blue */
    --secondary: #3b82f6;
    --secondary-glow: rgba(59, 130, 246, 0.2);
    --secondary-border: rgba(59, 130, 246, 0.4);
    
    /* ═══════════════════════════════════
       BACKGROUNDS - Layered Depth System
       ═══════════════════════════════════ */
    --bg-void: #000000;
    --bg-base: #06080c;
    --bg-surface: #0a0e14;
    --bg-elevated: #0f141c;
    --bg-card: #141a24;
    --bg-card-hover: #1a222e;
    --bg-panel: #1e2736;
    --bg-modal: #0f141c;
    
    /* Glassmorphism */
    --bg-glass: rgba(255, 255, 255, 0.02);
    --bg-glass-light: rgba(255, 255, 255, 0.04);
    --bg-glass-medium: rgba(255, 255, 255, 0.06);
    
    /* Hover / Active states */
    --bg-hover: rgba(255, 255, 255, 0.03);
    --bg-active: rgba(0, 229, 204, 0.06);
    --bg-active-strong: rgba(0, 229, 204, 0.12);
    --bg-selected: rgba(0, 229, 204, 0.08);
    
    /* Gradient Backgrounds */
    --bg-gradient-radial: radial-gradient(ellipse at top, rgba(0, 229, 204, 0.08) 0%, transparent 50%);
    --bg-gradient-terminal: linear-gradient(180deg, #0a0e14 0%, #06080c 100%);
    --bg-gradient-card: linear-gradient(145deg, rgba(20, 26, 36, 0.95) 0%, rgba(10, 14, 20, 0.98) 100%);
    --bg-gradient-panel: linear-gradient(135deg, rgba(30, 39, 54, 0.9) 0%, rgba(15, 20, 28, 0.95) 100%);
    --bg-overlay: rgba(0, 0, 0, 0.85);
    
    /* ═══════════════════════════════════
       TEXT COLORS - High Contrast Hierarchy
       ═══════════════════════════════════ */
    --text-bright: #ffffff;
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    --text-inverse: #06080c;
    
    /* ═══════════════════════════════════
       STATUS COLORS - Financial Data
       ═══════════════════════════════════ */
    /* Success / Bullish / Gain */
    --success: #00e5cc;
    --success-bright: #2cfee7;
    --success-dim: #00b3a1;
    --success-bg: rgba(0, 229, 204, 0.12);
    --success-bg-strong: rgba(0, 229, 204, 0.2);
    --success-border: rgba(0, 229, 204, 0.35);
    --success-glow: 0 0 20px rgba(0, 229, 204, 0.4);
    
    /* Error / Bearish / Loss */
    --error: #ff5757;
    --error-bright: #ff7575;
    --error-dim: #e04848;
    --error-bg: rgba(255, 87, 87, 0.12);
    --error-bg-strong: rgba(255, 87, 87, 0.2);
    --error-border: rgba(255, 87, 87, 0.35);
    --error-glow: 0 0 20px rgba(255, 87, 87, 0.4);
    
    /* Warning / Caution */
    --warning: #ffb547;
    --warning-bright: #ffc670;
    --warning-dim: #e5a03f;
    --warning-bg: rgba(255, 181, 71, 0.12);
    --warning-bg-strong: rgba(255, 181, 71, 0.2);
    --warning-border: rgba(255, 181, 71, 0.35);
    
    /* Info / Neutral Actions */
    --info: #3b82f6;
    --info-bright: #60a5fa;
    --info-dim: #2563eb;
    --info-bg: rgba(59, 130, 246, 0.12);
    --info-bg-strong: rgba(59, 130, 246, 0.2);
    --info-border: rgba(59, 130, 246, 0.35);
    
    /* Accent / AI / Premium */
    --accent: #a78bfa;
    --accent-bright: #c4b5fd;
    --accent-dim: #8b5cf6;
    --accent-bg: rgba(167, 139, 250, 0.12);
    --accent-bg-strong: rgba(167, 139, 250, 0.2);
    --accent-border: rgba(167, 139, 250, 0.35);
    --accent-gradient: linear-gradient(135deg, #a78bfa 0%, #3b82f6 100%);
    --accent-glow: 0 0 25px rgba(167, 139, 250, 0.4);
    
    /* ═══════════════════════════════════
       BORDERS - Subtle Definition
       ═══════════════════════════════════ */
    --border-subtle: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(0, 229, 204, 0.5);
    --border-glow: 0 0 0 1px var(--border), 0 0 0 4px var(--primary-glow);
    
    /* ═══════════════════════════════════
       SHADOWS - Depth & Elevation
       ═══════════════════════════════════ */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.6), 0 12px 24px rgba(0, 0, 0, 0.4);
    
    /* Colored shadows */
    --shadow-success: 0 4px 20px rgba(0, 229, 204, 0.25);
    --shadow-error: 0 4px 20px rgba(255, 87, 87, 0.25);
    --shadow-info: 0 4px 20px rgba(59, 130, 246, 0.25);
    --shadow-accent: 0 4px 20px rgba(167, 139, 250, 0.25);
    
    /* Glow effects */
    --glow-primary: 0 0 30px rgba(0, 229, 204, 0.3), 0 0 60px rgba(0, 229, 204, 0.1);
    --glow-success: 0 0 20px rgba(0, 229, 204, 0.4);
    --glow-error: 0 0 20px rgba(255, 87, 87, 0.4);
    
    /* ═══════════════════════════════════
       SPACING - 4px Base Grid
       ═══════════════════════════════════ */
    --space-0: 0;
    --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 */
    
    /* Legacy spacing variables */
    --spacing-xs: var(--space-1);
    --spacing-sm: var(--space-2);
    --spacing-md: var(--space-3);
    --spacing-lg: var(--space-4);
    --spacing-xl: var(--space-6);
    --spacing-2xl: var(--space-8);
    
    /* ═══════════════════════════════════
       BORDER RADIUS - Refined Corners
       ═══════════════════════════════════ */
    --radius-none: 0;
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-3xl: 24px;
    --radius-full: 9999px;
    
    /* ═══════════════════════════════════
       TYPOGRAPHY - Premium Font Stack
       ═══════════════════════════════════ */
    --font-sans: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    
    /* Font sizes - Compact scale */
    --text-3xs: 0.5625rem;   /* 9px */
    --text-2xs: 0.625rem;    /* 10px */
    --text-xs: 0.6875rem;    /* 11px */
    --text-sm: 0.75rem;      /* 12px */
    --text-base: 0.8125rem;  /* 13px */
    --text-md: 0.875rem;     /* 14px */
    --text-lg: 1rem;         /* 16px */
    --text-xl: 1.125rem;     /* 18px */
    --text-2xl: 1.25rem;     /* 20px */
    --text-3xl: 1.5rem;      /* 24px */
    --text-4xl: 1.875rem;    /* 30px */
    --text-5xl: 2.25rem;     /* 36px */
    
    /* Line heights */
    --leading-none: 1;
    --leading-tight: 1.2;
    --leading-snug: 1.35;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;
    
    /* Letter spacing */
    --tracking-tighter: -0.03em;
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.05em;
    --tracking-widest: 0.1em;
    
    /* ═══════════════════════════════════
       TRANSITIONS & ANIMATIONS
       ═══════════════════════════════════ */
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    --duration-instant: 50ms;
    --duration-fast: 100ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
    --duration-slower: 500ms;
    
    --transition-fast: 100ms var(--ease-out);
    --transition-normal: 200ms var(--ease-out);
    --transition-slow: 300ms var(--ease-out);
    --transition-colors: 150ms var(--ease-in-out);
    --transition-transform: 200ms var(--ease-out);
    --transition-all: all 200ms var(--ease-out);
    
    /* ═══════════════════════════════════
       Z-INDEX LAYERS
       ═══════════════════════════════════ */
    --z-below: -1;
    --z-base: 0;
    --z-above: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
    --z-overlay: 1000;
    
    /* ═══════════════════════════════════
       COMPONENT SPECIFIC
       ═══════════════════════════════════ */
    --header-height: 52px;
    --sidebar-width: 200px;
    --sidebar-collapsed: 60px;
    --content-max-width: 1920px;
}

/* ===================================
   GLOBAL RESET & BASE
   =================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

html, body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: var(--leading-normal);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Global background noise texture for premium feel */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        var(--bg-gradient-radial),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.015'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: var(--z-below);
}

/* Selection styling */
::selection {
    background: var(--primary-glow-strong);
    color: var(--text-bright);
}

/* ===================================
   TYPOGRAPHY
   =================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    margin: 0;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p {
    color: var(--text-secondary);
    margin: 0 0 var(--space-3);
    line-height: var(--leading-relaxed);
}

small {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ===================================
   LINKS
   =================================== */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-colors);
}

a:hover {
    color: var(--primary-hover);
}

a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ===================================
   BUTTONS - Premium Design
   =================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-all);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--border-glow);
}

.btn:active {
    transform: translateY(1px);
}

/* Primary Button - Glowing CTA */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: var(--text-inverse);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-primary:hover {
    box-shadow: var(--shadow-success), inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* Outline Variants */
.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary-border);
}

.btn-outline-primary:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.btn-outline-danger {
    background: transparent;
    color: var(--error);
    border-color: var(--error-border);
}

.btn-outline-danger:hover {
    background: var(--error-bg);
    border-color: var(--error);
}

/* Button Sizes */
.btn-xs {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
}

/* Icon Button */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* ===================================
   FORM CONTROLS - Trading Terminal Style
   =================================== */
.form-control, .form-select {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    transition: var(--transition-all);
}

.form-control:hover {
    border-color: var(--border-medium);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-dim);
}

.form-control:disabled {
    background: var(--bg-base);
    color: var(--text-dim);
    cursor: not-allowed;
    opacity: 0.5;
}

.form-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

/* Compact input */
.form-control-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
}

/* ===================================
   CARDS - Glassmorphism Premium
   =================================== */
.card {
    background: var(--bg-gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
    transition: var(--transition-all);
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.card-header h3, .card-header h4, .card-header h5 {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: var(--tracking-wide);
}

.card-body {
    padding: var(--space-4);
    position: relative;
}

.card-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
}

/* Card with accent top border */
.card-accent {
    border-top: 2px solid var(--primary);
}

.card-accent::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(180deg, var(--primary-glow) 0%, transparent 100%);
    pointer-events: none;
}

/* Stat Card - Compact Metric Display */
.stat-card {
    background: var(--bg-gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    transition: var(--transition-all);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-label {
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-none);
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--error); }

.stat-change {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

/* ===================================
   TABLES - Data Grid Style
   =================================== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
}

.table th {
    font-size: var(--text-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    color: var(--text-muted);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) var(--space-3);
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: var(--z-above);
}

.table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
    background: transparent;
    transition: background var(--transition-fast);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:hover td {
    background: transparent;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Compact table variant */
.table-compact th,
.table-compact td {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
}

/* Clickable rows */
.table-hover tbody tr {
    cursor: pointer;
}

/* Column alignment */
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* ===================================
   BADGES - Status & Labels
   =================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-sans);
    font-size: var(--text-2xs);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    line-height: var(--leading-none);
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.badge-danger {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info-border);
}

.badge-accent {
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.badge-neutral {
    background: var(--bg-glass-medium);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Pill badge */
.badge-pill {
    border-radius: var(--radius-full);
    padding: 2px 8px;
}

/* Dot indicator badge */
.badge-dot {
    position: relative;
    padding-left: 14px;
}

.badge-dot::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ===================================
   FINANCIAL DATA STYLING
   =================================== */
.price, .number, .percent {
    font-family: var(--font-mono);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    font-variant-numeric: tabular-nums;
}

.positive, .gain, .bullish { color: var(--success) !important; }
.negative, .loss, .bearish { color: var(--error) !important; }
.neutral { color: var(--text-secondary) !important; }

/* ===================================
   BULL/BEAR ICON CLASSES
   =================================== */
.icon-bull,
.icon-bear {
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
}

.icon-bull {
    background-image: url('images/Bull.png');
}

.icon-bear {
    background-image: url('images/Bear.png');
}

/* Icon sizes */
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 24px; height: 24px; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 48px; height: 48px; }

/* Inline img tag styling for bull/bear */
img.bull-icon,
img.bear-icon {
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
}

img.bull-icon { filter: drop-shadow(0 0 2px rgba(63, 185, 80, 0.3)); }
img.bear-icon { filter: drop-shadow(0 0 2px rgba(248, 81, 73, 0.3)); }

/* Size classes for img tags */
img.icon-xs { width: 12px; height: 12px; }
img.icon-sm { width: 16px; height: 16px; }
img.icon-md { width: 24px; height: 24px; }
img.icon-lg { width: 32px; height: 32px; }
img.icon-xl { width: 48px; height: 48px; }

/* Price with glow */
.price-glow.positive { text-shadow: var(--glow-success); }
.price-glow.negative { text-shadow: var(--glow-error); }

/* Symbol style */
.symbol {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

.symbol-link {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: var(--tracking-tight);
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.symbol-link:hover {
    color: var(--primary);
}

/* ===================================
   SCROLLBAR STYLING
   =================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--bg-base);
}

/* ===================================
   LOADING STATES
   =================================== */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-spinner.lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface) 0%,
        var(--bg-elevated) 40%,
        var(--bg-elevated) 60%,
        var(--bg-surface) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================================
   ANIMATIONS
   =================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes glow-pulse {
    0%, 100% { 
        box-shadow: 0 0 4px var(--primary-glow);
    }
    50% { 
        box-shadow: 0 0 12px var(--primary-glow), 0 0 20px var(--primary-glow);
    }
}

@keyframes border-glow {
    0%, 100% { border-color: var(--primary-border); }
    50% { border-color: var(--primary); }
}

.animate-fadeIn { animation: fadeIn var(--duration-normal) var(--ease-out); }
.animate-slideUp { animation: slideUp var(--duration-normal) var(--ease-out); }
.animate-slideDown { animation: slideDown var(--duration-normal) var(--ease-out); }
.animate-slideRight { animation: slideRight var(--duration-normal) var(--ease-out); }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }

/* ===================================
   UTILITY CLASSES
   =================================== */
/* Colors */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--error) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-accent { color: var(--accent) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary { color: var(--text-primary) !important; }
.text-bright { color: var(--text-bright) !important; }

/* Backgrounds */
.bg-success { background: var(--success-bg) !important; }
.bg-danger { background: var(--error-bg) !important; }
.bg-warning { background: var(--warning-bg) !important; }
.bg-info { background: var(--info-bg) !important; }
.bg-accent { background: var(--accent-bg) !important; }
.bg-surface { background: var(--bg-surface) !important; }
.bg-elevated { background: var(--bg-elevated) !important; }

/* Typography */
.font-mono { font-family: var(--font-mono) !important; }
.font-display { font-family: var(--font-display) !important; }
.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.font-medium { font-weight: 500 !important; }

/* Text sizes */
.text-2xs { font-size: var(--text-2xs) !important; }
.text-xs { font-size: var(--text-xs) !important; }
.text-sm { font-size: var(--text-sm) !important; }
.text-base { font-size: var(--text-base) !important; }
.text-md { font-size: var(--text-md) !important; }
.text-lg { font-size: var(--text-lg) !important; }
.text-xl { font-size: var(--text-xl) !important; }

/* Spacing utilities */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-3) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }

/* ===================================
   MARKET INDICATORS
   =================================== */
.market-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
}

.market-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.market-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: glow-pulse 2s ease-in-out infinite;
}

.market-dot.open {
    background: var(--success);
}

.market-dot.closed {
    background: var(--error);
}

.market-dot.closed::after {
    animation: none;
}

.market-dot.premarket,
.market-dot.extended {
    background: var(--warning);
}

/* ===================================
   PROGRESS & METERS
   =================================== */
.meter-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--duration-slow) var(--ease-out);
}

.meter-fill.success { background: linear-gradient(90deg, var(--success-dim), var(--success)); }
.meter-fill.error { background: linear-gradient(90deg, var(--error-dim), var(--error)); }
.meter-fill.info { background: linear-gradient(90deg, var(--info-dim), var(--info)); }
.meter-fill.accent { background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }

/* Spectrum bar (Fear/Greed style) */
.spectrum-bar {
    height: 8px;
    background: linear-gradient(90deg, 
        var(--error) 0%, 
        var(--warning) 50%, 
        var(--success) 100%
    );
    border-radius: 4px;
    position: relative;
}

.spectrum-marker {
    position: absolute;
    top: 50%;
    width: 3px;
    height: 14px;
    background: var(--text-bright);
    border-radius: 2px;
    transform: translate(-50%, -50%);
    box-shadow: var(--shadow-sm);
}

/* ===================================
   DIVIDERS & SEPARATORS
   =================================== */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-3) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border);
    margin: 0 var(--space-3);
}

.section-header {
    font-size: var(--text-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

/* ===================================
   TOOLTIPS
   =================================== */
.tooltip-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    color: var(--text-primary);
    max-width: 280px;
    z-index: var(--z-tooltip);
}

/* ===================================
   MODAL OVERLAY
   =================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--duration-fast) var(--ease-out);
}

.modal-content {
    background: var(--bg-gradient-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: var(--space-5);
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ===================================
   AI / PREMIUM FEATURES
   =================================== */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-2xs);
    font-weight: 700;
    padding: 2px 8px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    box-shadow: var(--shadow-accent);
    animation: border-glow 3s ease-in-out infinite;
}

.ai-glow {
    position: relative;
}

.ai-glow::after {
    content: '';
    position: absolute;
    inset: -4px;
    background: var(--accent-gradient);
    border-radius: inherit;
    opacity: 0.25;
    filter: blur(8px);
    z-index: var(--z-below);
}

/* ===================================
   BLAZOR ERROR UI
   =================================== */
#blazor-error-ui {
    background: var(--error);
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: var(--space-3) var(--space-4);
    position: fixed;
    width: 100%;
    z-index: var(--z-overlay);
    font-size: var(--text-sm);
    color: white;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--space-4);
    top: var(--space-3);
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
    margin-left: var(--space-2);
}

.blazor-error-boundary {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    padding: var(--space-4);
    color: var(--error);
    border-radius: var(--radius-lg);
}

/* ===================================
   CHART CONTAINER
   =================================== */
.chart-container {
    background: var(--bg-gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    position: relative;
    overflow: hidden;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--info), transparent);
}

/* ===================================
   SYMBOL PRICING COMPONENT
   =================================== */
.symbol-pricing {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-glass-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: var(--transition-all);
}

.symbol-pricing:hover {
    border-color: var(--border-medium);
    background: var(--bg-glass-medium);
}

.symbol-pricing .symbol-name {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--text-primary);
    padding: 1px 6px;
    background: var(--bg-glass);
    border-radius: var(--radius-xs);
}

.symbol-pricing .symbol-price {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: var(--text-sm);
}

.symbol-pricing.price-up .symbol-price { color: var(--success); }
.symbol-pricing.price-down .symbol-price { color: var(--error); }

/* ===================================
   QUICK STATS GRID
   =================================== */
.quick-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.quick-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 var(--space-4);
    border-right: 1px solid var(--border);
}

.quick-stat:last-child {
    border-right: none;
}

.quick-stats .stat-number {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: var(--leading-none);
}

.quick-stats .stat-number.text-success { color: var(--success); }
.quick-stats .stat-number.text-danger { color: var(--error); }

.quick-stats .stat-desc {
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ===================================
   POSITIONS TABLE OVERRIDES
   =================================== */
.positions-table {
    width: 100%;
}

.positions-table td,
.positions-table th {
    color: var(--text-primary);
}

.positions-table .symbol-link {
    color: var(--text-primary);
    font-weight: 700;
}

.positions-table .symbol-link:hover {
    color: var(--primary);
}

/* ===================================
   ETF / STOCK CARDS
   =================================== */
.etf-card {
    position: relative;
    background: var(--bg-gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: var(--transition-all);
}

.etf-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.etf-card.positive::before { background: var(--success); }
.etf-card.negative::before { background: var(--error); }

.etf-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* ===================================
   RESPONSIVE ADJUSTMENTS
   =================================== */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .card-body {
        padding: var(--space-3);
    }
    
    .quick-stats {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .quick-stat {
        flex-direction: row;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: var(--space-2) 0;
    }
    
    .quick-stat:last-child {
        border-bottom: none;
    }
}

@media (min-width: 1600px) {
    html {
        font-size: 15px;
    }
}

/* ===================================
   VALIDATION STATES
   =================================== */
.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--error);
}

.validation-message {
    color: var(--error);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

/* ===================================
   CONTENT AREA DEFAULTS
   =================================== */
.content {
    padding: var(--space-4) 0;
}

.content-area {
    padding: var(--space-4) var(--space-5);
    max-width: var(--content-max-width);
}

@media (max-width: 768px) {
    .content-area {
        padding: var(--space-3);
    }
}

/* ===================================
   SIDEBAR CONTAINER
   =================================== */
.sidebar-container {
    transition: width var(--duration-slow) var(--ease-out);
}

.sidebar-container.collapsed {
    width: var(--sidebar-collapsed) !important;
}

.sidebar-container.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-container.collapsed .nav-link {
    justify-content: center;
}

/* ===================================
   HEADER DROPDOWN OVERRIDES (Global)
   Override scoped CSS for JS-controlled show state
   =================================== */

/* Nav dropdown container */
.nav-dropdown {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Dropdown menu base styles - MUST be global for JS to work */
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-2);
    z-index: 1000;
    margin-top: 4px;
    
    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 150ms ease, visibility 150ms ease, transform 150ms ease;
    pointer-events: none;
}

/* Dropdown menu SHOW state */
.nav-dropdown-menu.show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* User menu positioning - right aligned */
.nav-dropdown-menu.user-menu {
    left: auto;
    right: 0;
    min-width: 240px;
}

/* Dropdown items */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-glass-light);
    color: var(--text-primary);
}

.dropdown-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.dropdown-item:hover svg {
    opacity: 1;
}

/* Arrow rotation */
.dropdown-arrow {
    transition: transform var(--transition-fast);
}

.dropdown-arrow.rotated {
    transform: rotate(180deg);
}
