/**
 * Sweat Station - PREMIUM EDITION
 * High-performance dark theme with glassmorphism, animations, and depth.
 * Inspired by: Bloomberg Terminal, Robinhood, Modern Trading Platforms
 */

/* ============================================
   GOOGLE FONTS IMPORT
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    /* Brand Colors - Premium Electric Blue */
    --brand-primary: #3b82f6;
    --brand-secondary: #8b5cf6;
    --brand-dark: #0a0f1c;
    --brand-darker: #050810;
    --brand-accent: #06ffa5;
    --brand-glow: rgba(59, 130, 246, 0.5);

    /* Functional Colors */
    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.4);
    --color-danger: #ef4444;
    --color-danger-glow: rgba(239, 68, 68, 0.4);
    --color-warning: #f59e0b;
    --color-text-main: #f1f5f9;
    --color-text-muted: #64748b;

    /* Surfaces - Deep Glass Effect */
    --surface-base: rgba(10, 15, 28, 0.95);
    --surface-card: rgba(15, 23, 42, 0.8);
    --surface-card-solid: #0f172a;
    --surface-elevated: rgba(30, 41, 59, 0.9);
    --surface-hover: rgba(51, 65, 85, 0.6);
    --surface-border: rgba(71, 85, 105, 0.3);
    --surface-border-glow: rgba(59, 130, 246, 0.3);

    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    /* Spacing & Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Effects */
    --blur-sm: 8px;
    --blur-md: 16px;
    --blur-lg: 24px;
    --shadow-glow: 0 0 40px var(--brand-glow);
    --shadow-card: 
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 2px 4px -1px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --shadow-elevated: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(59, 130, 246, 0.15);

    /* Transitions */
    --trans-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --trans-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --trans-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--brand-darker);
    color: var(--color-text-main);
    font-family: var(--font-main);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Animated mesh gradient background */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(6, 255, 165, 0.05) 0%, transparent 60%),
        linear-gradient(180deg, var(--brand-darker) 0%, var(--brand-dark) 100%);
    z-index: -2;
    animation: meshShift 20s ease-in-out infinite alternate;
}

@keyframes meshShift {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(15deg); }
}

/* Subtle grid pattern overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    pointer-events: none;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: white;
    margin: 0;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   COMPONENTS: CARDS (Premium Glassmorphism)
   ============================================ */
.dk-card {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.7) 0%, 
        rgba(15, 23, 42, 0.8) 50%,
        rgba(10, 15, 28, 0.9) 100%);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: 
        transform var(--trans-smooth), 
        box-shadow var(--trans-smooth), 
        border-color var(--trans-smooth);
    position: relative;
}

/* Subtle inner glow */
.dk-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
}

.dk-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-elevated);
    border-color: var(--surface-border-glow);
}

.dk-card-header {
    background: linear-gradient(90deg, 
        rgba(59, 130, 246, 0.1) 0%, 
        rgba(139, 92, 246, 0.05) 50%,
        transparent 100%);
    border-bottom: 1px solid var(--surface-border);
    padding: 20px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

/* Accent bar on header */
.dk-card-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    border-radius: 0 2px 2px 0;
}

/* ============================================
   KPI CARDS (Bet Tracker Stats)
   ============================================ */
.kpi-card {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.6) 0%, 
        rgba(15, 23, 42, 0.8) 100%);
    backdrop-filter: blur(var(--blur-sm));
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    transition: all var(--trans-smooth);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--brand-primary) 50%, 
        transparent 100%);
    opacity: 0;
    transition: opacity var(--trans-smooth);
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--surface-border-glow);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--brand-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 8px;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

/* ============================================
   COMPONENTS: BUTTONS (Premium)
   ============================================ */
button, .dk-btn {
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--trans-fast);
}

.dk-btn {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 15px var(--brand-glow);
    position: relative;
    overflow: hidden;
}

.dk-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: left 0.5s ease;
}

.dk-btn:hover::before {
    left: 100%;
}

.dk-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px var(--brand-glow);
}

.dk-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Success Button */
.btn-success, button[style*="backgroundColor: rgb(15, 81, 50)"], 
button[style*="background-color: #0f5132"] {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 4px 15px var(--color-success-glow) !important;
    font-weight: 600 !important;
    transition: all var(--trans-fast) !important;
}

.btn-success:hover, button[style*="backgroundColor: rgb(15, 81, 50)"]:hover,
button[style*="background-color: #0f5132"]:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px var(--color-success-glow) !important;
}

/* Danger Button */
button[style*="background-color"][style*="ef4444"],
button[style*="backgroundColor"][style*="red"] {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important;
    box-shadow: 0 4px 15px var(--color-danger-glow) !important;
}

/* ============================================
   COMPONENTS: TABS (Sleek)
   ============================================ */
.nav-tabs {
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: 24px;
    gap: 4px;
}

.nav-link {
    color: var(--color-text-muted) !important;
    font-weight: 500;
    background: transparent !important;
    border: none !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
    padding: 14px 24px;
    transition: all var(--trans-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    transition: width var(--trans-smooth);
}

.nav-link:hover {
    color: var(--color-text-main) !important;
    background: rgba(59, 130, 246, 0.05) !important;
}

.nav-link:hover::after {
    width: 60%;
}

.nav-link.active {
    color: white !important;
    background: rgba(59, 130, 246, 0.1) !important;
}

.nav-link.active::after {
    width: 100%;
}

/* ============================================
   COMPONENTS: TABLE (Data Grid)
   ============================================ */
.table-dark {
    --bs-table-bg: transparent;
    color: var(--color-text-main);
}

.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 0.9rem;
}

.table thead th {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--surface-border);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table thead th:first-child {
    border-top-left-radius: var(--radius-md);
}

.table thead th:last-child {
    border-top-right-radius: var(--radius-md);
}

.table tbody tr {
    transition: background-color var(--trans-fast);
}

.table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.table tbody td {
    padding: 16px 20px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(71, 85, 105, 0.2);
}

/* Status badges */
td .badge {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

/* ============================================
   COMPONENTS: FORM ELEMENTS
   ============================================ */
.form-control, .form-select, .Select-control, input, select {
    background: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid var(--surface-border) !important;
    color: var(--color-text-main) !important;
    border-radius: var(--radius-md) !important;
    padding: 12px 16px !important;
    font-family: var(--font-main) !important;
    transition: all var(--trans-fast) !important;
}

.form-control:focus, .form-select:focus, input:focus, select:focus {
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 3px var(--brand-glow), inset 0 1px 2px rgba(0,0,0,0.2) !important;
    outline: none !important;
}

/* Dropdown menus */
.Select-menu-outer, .dropdown-menu {
    background: var(--surface-card-solid) !important;
    border: 1px solid var(--surface-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-elevated) !important;
}

label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
}

/* ============================================
   CHARTS (Plotly Integration)
   ============================================ */
.js-plotly-plot .plotly .main-svg {
    border-radius: var(--radius-md);
}

/* ============================================
   LOADING STATES
   ============================================ */
._dash-loading {
    background: linear-gradient(90deg, 
        var(--surface-card) 25%, 
        var(--surface-elevated) 50%, 
        var(--surface-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading spinner enhancement */
.dash-spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

/* ============================================
   DEEP RESEARCH OUTPUT (Premium)
   ============================================ */
.deep-research-markdown {
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.9) 0%, 
        rgba(10, 15, 28, 0.95) 100%);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    color: var(--color-text-main);
    line-height: 1.7;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.deep-research-markdown h1,
.deep-research-markdown h2,
.deep-research-markdown h3 {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--surface-border);
}

.deep-research-markdown h1:first-child,
.deep-research-markdown h2:first-child {
    margin-top: 0;
}

.deep-research-markdown p {
    margin-bottom: 1em;
    color: #e2e8f0;
}

.deep-research-markdown ul, .deep-research-markdown ol {
    padding-left: 24px;
    margin-bottom: 1em;
}

.deep-research-markdown li {
    margin-bottom: 8px;
    position: relative;
}

.deep-research-markdown li::marker {
    color: var(--brand-primary);
}

.deep-research-markdown strong {
    color: white;
    font-weight: 700;
}

.deep-research-markdown blockquote {
    border-left: 3px solid var(--brand-primary);
    padding-left: 20px;
    margin: 1.5em 0;
    background: rgba(59, 130, 246, 0.05);
    padding: 16px 20px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--color-text-muted);
}

.deep-research-markdown code {
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--brand-accent);
}

/* ============================================
   STREAMING PANELS (Terminal Style)
   ============================================ */
.stream-panel {
    background: linear-gradient(180deg, 
        rgba(5, 8, 16, 0.95) 0%, 
        rgba(10, 15, 28, 0.98) 100%) !important;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: var(--color-text-main) !important;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(0, 0, 0, 0.2);
}

.stream-panel h4 {
    color: var(--brand-accent) !important;
    font-family: var(--font-main);
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--surface-border);
    font-weight: 600;
}

/* Custom scrollbar */
.stream-panel::-webkit-scrollbar {
    width: 8px;
}

.stream-panel::-webkit-scrollbar-track {
    background: var(--surface-card);
    border-radius: 4px;
}

.stream-panel::-webkit-scrollbar-thumb {
    background: var(--surface-border);
    border-radius: 4px;
}

.stream-panel::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-success, .text-dk-green {
    color: var(--color-success) !important;
}

.text-danger {
    color: var(--color-danger) !important;
}

.text-accent {
    color: var(--brand-accent) !important;
}

.text-gradient {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow-success {
    box-shadow: 0 0 20px var(--color-success-glow);
}

.glow-danger {
    box-shadow: 0 0 20px var(--color-danger-glow);
}

.glow-primary {
    box-shadow: 0 0 20px var(--brand-glow);
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Pulse animation for live indicators */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --radius-lg: 12px;
        --radius-xl: 16px;
    }

    body::after {
        display: none;
    }

    .dk-card {
        border-radius: var(--radius-md);
        margin: 0 -12px;
    }

    .nav-link {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .kpi-value {
        font-size: 1.8rem;
    }

    .table thead th,
    .table tbody td {
        padding: 12px 14px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body::before, body::after {
        display: none;
    }

    .dk-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}