/**
 * Neural Edge Quant Dashboard - Design System
 * Bloomberg Terminal / NSA Aesthetic
 */

/* ============================================
   CSS VARIABLES - Design Tokens
   ============================================ */
:root {
    /* Base colors */
    --bg-primary: #0a0f14;
    --bg-secondary: #0f1419;
    --bg-tertiary: #151c24;
    --bg-elevated: #1a222c;
    --bg-hover: #1e2730;
    
    /* Border colors */
    --border-primary: #1e2a36;
    --border-secondary: #2a3a4a;
    --border-accent: #3a4a5a;
    
    /* Text colors */
    --text-primary: #e8eef4;
    --text-secondary: #8896a4;
    --text-muted: #8896a4;
    --text-dim: #3a4a5a;
    
    /* Semantic colors */
    --positive: #00d4aa;
    --positive-dim: rgba(0, 212, 170, 0.15);
    --positive-muted: #00a88a;
    
    --negative: #ff4757;
    --negative-dim: rgba(255, 71, 87, 0.15);
    --negative-muted: #cc3a47;
    
    --warning: #ffa502;
    --warning-dim: rgba(255, 165, 2, 0.15);
    
    --info: #3498db;
    --info-dim: rgba(52, 152, 219, 0.15);
    
    --accent: #00b4d8;
    --accent-dim: rgba(0, 180, 216, 0.15);
    
    /* Chart colors */
    --chart-line: #00d4aa;
    --chart-area: rgba(0, 212, 170, 0.1);
    --chart-grid: #1e2a36;
    --chart-crosshair: #3a4a5a;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    
    /* Font sizes */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
    --text-lg: 14px;
    --text-xl: 16px;
    --text-2xl: 20px;
    --text-3xl: 24px;
    --text-4xl: 32px;
    
    /* Transitions */
    --transition-fast: 0.1s ease;
    --transition-base: 0.2s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.font-mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

.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-4xl { font-size: var(--text-4xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-accent { color: var(--accent); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }
.tracking-wider { letter-spacing: 0.1em; }

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.grid {
    display: grid;
    gap: var(--space-md);
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ============================================
   COMPONENTS - Cards
   ============================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.card-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-body {
    padding: var(--space-md);
}

.card-flush .card-body {
    padding: 0;
}

/* Stat Card */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.stat-card-compact {
    padding: var(--space-sm) var(--space-md);
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.2;
}

.stat-value-lg {
    font-size: var(--text-3xl);
}

.stat-value-sm {
    font-size: var(--text-lg);
}

.stat-delta {
    font-size: var(--text-xs);
    font-family: 'JetBrains Mono', monospace;
    margin-top: var(--space-xs);
}

/* ============================================
   COMPONENTS - Navigation
   ============================================ */
.nav-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 var(--space-lg);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--positive) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo svg {
    width: 18px;
    height: 18px;
    color: var(--bg-primary);
}

.nav-title {
    font-size: 20px;
    color: var(--text-primary);
}

.nav-version {
    font-size: var(--text-xs);
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

.nav-tabs {
    display: flex;
    gap: var(--space-xs);
}

.nav-tab {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-base);
    border: 1px solid transparent;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-tab.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: rgba(0, 180, 216, 0.3);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--positive);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-dot.offline {
    background: var(--negative);
    animation: none;
}

/* ============================================
   COMPONENTS - Tables
   ============================================ */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-secondary);
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.data-table th.text-right,
.data-table td.text-right {
    text-align: right;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-primary);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table .mono {
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   COMPONENTS - Badges & Tags
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-yes {
    background: var(--positive-dim);
    color: var(--positive);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.badge-no {
    background: var(--negative-dim);
    color: var(--negative);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.badge-open {
    background: var(--info-dim);
    color: var(--info);
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.badge-deployed {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(0, 180, 216, 0.3);
}

.badge-win {
    background: var(--positive-dim);
    color: var(--positive);
}

.badge-loss {
    background: var(--negative-dim);
    color: var(--negative);
}

.badge-neutral {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-secondary);
}

/* ============================================
   COMPONENTS - Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
}

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

.btn-icon {
    padding: var(--space-sm);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

.btn-primary {
    background: var(--accent-dim);
    border-color: rgba(0, 180, 216, 0.3);
    color: var(--accent);
}

.btn-primary:hover {
    background: rgba(0, 180, 216, 0.25);
}

/* ============================================
   COMPONENTS - Charts
   ============================================ */
.chart-container {
    position: relative;
    height: 100%;
    min-height: 200px;
}

.chart-legend {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-primary);
    font-size: var(--text-xs);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

/* ============================================
   COMPONENTS - Progress Bars
   ============================================ */
.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-fill.positive { background: var(--positive); }
.progress-fill.negative { background: var(--negative); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.info { background: var(--info); }

/* ============================================
   COMPONENTS - Tooltips
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   UTILITIES
   ============================================ */
.p-0 { padding: 0; }
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }

.m-0 { margin: 0; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

.border { border: 1px solid var(--border-primary); }
.border-b { border-bottom: 1px solid var(--border-primary); }

.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary { background: var(--bg-tertiary); }

.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }

.whitespace-nowrap { white-space: nowrap; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

.cursor-pointer { cursor: pointer; }

.transition { transition: var(--transition-base); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .grid-cols-5 { grid-template-columns: repeat(4, 1fr); }
    .grid-cols-6 { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-5 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-6 { grid-template-columns: repeat(3, 1fr); }
    
    .hide-tablet { display: none; }
}

@media (max-width: 768px) {
    :root {
        --space-lg: 16px;
    }
    
    .container {
        padding: 0 var(--space-md);
    }
    
    .grid-cols-2 { grid-template-columns: 1fr; }
    .grid-cols-3 { grid-template-columns: 1fr; }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    
    .nav-tabs {
        display: none;
    }
    
    .hide-mobile { display: none; }
    
    .stat-value {
        font-size: var(--text-xl);
    }
    
    .stat-value-lg {
        font-size: var(--text-2xl);
    }
}

/* Mobile nav dropdown */
.nav-mobile-toggle {
    display: none;
    padding: var(--space-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-mobile-toggle {
        display: flex;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.3s ease;
}

/* Staggered animation for grid items */
.stagger-animation > * {
    animation: slideUp 0.3s ease backwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.3s; }

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
}

.sortable:hover {
    background: var(--bg-hover);
}

.sortable::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-dim);
    margin-top: 2px;
}

.sortable.asc::after {
    border-top-color: transparent;
    border-bottom-color: var(--accent);
    margin-top: -6px;
}

.sortable.desc::after {
    border-top-color: var(--accent);
}