/* Polymarket Bot System — Shared Design System v2.0 */
/* Light Theme Default + Dark Theme Alternative */

/* ---- Light Theme (Default) ---- */
:root {
    /* Backgrounds */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f1f5f9;
    --bg-overlay: rgba(0, 0, 0, 0.4);

    /* Borders */
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: rgba(37, 99, 235, 0.5);

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Sidebar — Helio Navy */
    --sidebar-bg: #1e3a5f;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-hover: rgba(255, 255, 255, 0.9);
    --sidebar-active-bg: rgba(255, 255, 255, 0.12);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    /* Header */
    --header-bg: #ffffff;
    --header-border: #e2e8f0;
    --header-text: #1e293b;

    /* Shadows */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-dropdown: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ---- Dark Theme ---- */
[data-theme="dark"] {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-input: #1e293b;
    --bg-overlay: rgba(0, 0, 0, 0.6);

    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --sidebar-bg: #111827;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-active-bg: rgba(99, 102, 241, 0.12);
    --sidebar-active-text: #e2e8f0;
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --header-bg: rgba(11, 15, 25, 0.8);
    --header-border: rgba(255, 255, 255, 0.06);
    --header-text: #f1f5f9;

    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ---- Theme-Independent Variables ---- */
:root {
    /* Brand */
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-bg: rgba(99, 102, 241, 0.1);

    /* Semantic (legacy names — keep for backward compat) */
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --green-glow: rgba(34, 197, 94, 0.4);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --red-glow: rgba(239, 68, 68, 0.4);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.15);
    --amber: #f59e0b;
    --cyan: #0ea5e9;
    --purple: #8b5cf6;

    /* Helio-Finanz Semantic Colors */
    --success: #16a34a;
    --success-light: #dcfce7;
    --success-bg: rgba(22, 163, 74, 0.1);
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #2563eb;
    --info-light: #eff6ff;
    --info-bg: rgba(37, 99, 235, 0.1);

    /* Bot Colors */
    --maker: #22c55e;
    --copier: #f97316;
    --value: #0ea5e9;
    --exchange: #ec4899;
    --portal: #6366f1;
    --trainer: #f59e0b;

    /* Bot Identity (override per dashboard) */
    --bot-color: var(--accent);
    --bot-color-glow: var(--accent-glow);

    /* Spacing (8px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --text-xs: 10px;
    --text-sm: 11px;
    --text-base: 12px;
    --text-md: 13px;
    --text-lg: 14px;
    --text-xl: 16px;
    --text-2xl: 20px;
    --text-3xl: 28px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ---- Global Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Scrollbars (Light Default) ---- */
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.15) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* Scrollbar Dark Theme Override */
[data-theme="dark"] { scrollbar-color: rgba(255,255,255,0.08) transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ---- Base Body ---- */
body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background gradient — Dark Theme only */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite alternate;
}

/* ---- Shared Animations ---- */
@keyframes bgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, 3%); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0; transform: scale(1.3); }
}
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 4px var(--green-glow); }
    50% { box-shadow: 0 0 12px var(--green-glow); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Toast (unified top-right) ---- */
.toast {
    position: fixed; top: 20px; right: 20px;
    padding: 12px 20px; border-radius: var(--radius-md);
    font-size: var(--text-base); z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 400px; backdrop-filter: blur(12px);
}
.toast.show { transform: translateX(0); }
.toast.success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--green); }
.toast.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--red); }
.toast.warning { background: rgba(234, 179, 8, 0.15); border: 1px solid rgba(234, 179, 8, 0.3); color: var(--yellow); }

/* Stale Data Indicator */
.data-stale { opacity: 0.5; position: relative; }
.data-stale::after { content: '\26A0'; position: absolute; top: -4px; right: -4px; font-size: 12px; color: var(--yellow); }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
}
.badge.live, .badge-live { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.3); }
.badge.paper, .badge-paper { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(234, 179, 8, 0.3); }
.badge.offline, .badge-offline { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ---- Buttons ---- */
.btn {
    padding: 6px 14px; border-radius: var(--radius-sm);
    font-size: var(--text-sm); font-weight: 600;
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); cursor: pointer;
    transition: all var(--transition-fast); font-family: inherit;
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.btn-danger { border-color: rgba(239,68,68,0.3); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-success { border-color: rgba(34,197,94,0.3); color: var(--green); }
.btn-success:hover { background: var(--green-bg); }
.btn-save { background: var(--accent); color: white; border-color: transparent; }
.btn-save:hover { opacity: 0.9; }

/* ---- Header (shared structure) ---- */
.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 28px; background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    position: sticky; top: 0; z-index: 100;
}
[data-theme="dark"] .header { backdrop-filter: blur(20px); }
.header-left { display: flex; align-items: center; gap: 12px; }
.header h1 {
    font-size: 16px; font-weight: 700; letter-spacing: 0.5px;
    color: var(--header-text);
}
[data-theme="dark"] .header h1 {
    background: linear-gradient(135deg, #c7d2fe, #a78bfa);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-stats { display: flex; align-items: center; gap: 50px; }
.header-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.header-stat-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.header-stat-label { font-size: 9px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* ---- Logo Pulse ---- */
.logo-pulse {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--logo-color, var(--bot-color)), var(--logo-color-dark, var(--bot-color)));
    display: flex; align-items: center; justify-content: center;
    position: relative; font-size: 16px; font-weight: 700; color: #fff;
}
.logo-pulse .logo-emoji { filter: brightness(0) invert(1); font-size: 20px; line-height: 1; }
.logo-pulse::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid var(--logo-color, var(--bot-color));
    animation: pulse 2s ease-in-out infinite;
}

/* ---- Connection Dot ---- */
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); transition: background 0.3s; }
.conn-dot.connected { background: var(--green); box-shadow: 0 0 8px var(--green-glow); animation: dotPulse 2s infinite; }

/* ---- Nav Bar ---- */
.nav-bar {
    position: sticky; top: 56px; z-index: 99;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    display: flex; justify-content: center; gap: 0; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 0 20px;
}
[data-theme="dark"] .nav-bar { backdrop-filter: blur(20px); }
.nav-bar::-webkit-scrollbar { display: none; }
.nav-link {
    padding: 10px 16px; color: var(--text-secondary); text-decoration: none;
    font-size: 13px; font-weight: 500; white-space: nowrap;
    border-bottom: 2px solid transparent; transition: all 0.2s;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--bot-color); border-bottom-color: var(--bot-color); }
[id^="section-"] { scroll-margin-top: 110px; }

/* ---- Container ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 28px; }

/* ---- KPI Grid ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px; transition: all 0.3s;
    opacity: 0; transform: translateY(12px);
    animation: fadeUp 0.6s ease-out forwards;
    box-shadow: var(--shadow-card);
}
[data-theme="dark"] .kpi-card { backdrop-filter: blur(12px); }
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-sub { font-size: 13px; font-weight: 500; margin-top: 6px; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 12px; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 256px;
    background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column; z-index: 200;
    transition: transform 0.3s ease;
}
.sidebar-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; margin: 2px 8px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); cursor: pointer; transition: all 0.15s;
    font-size: 13px; font-weight: 500; text-decoration: none;
    background: none; border: none;
}
.sidebar-nav-item:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-hover); }
.sidebar-nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Tabs (Helio-Finanz Style) ---- */
.tab-nav { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab-btn {
    padding: 10px 16px; color: var(--text-secondary); font-size: 13px; font-weight: 500;
    border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s;
    background: none; border-top: none; border-left: none; border-right: none;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--bot-color, var(--accent)); border-bottom-color: var(--bot-color, var(--accent)); }

/* ---- Toggle Switch (CSS-only) ---- */
.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border);
    border-radius: 10px; transition: 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    left: 2px; bottom: 2px; background: white;
    border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--bot-color, var(--accent)); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ---- Theme Toggle Button ---- */
.theme-toggle {
    width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg-card);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; color: var(--text-secondary);
}
.theme-toggle:hover { border-color: var(--border-hover); color: var(--text-primary); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ---- Ampel-System (Traffic Light) ---- */
.ampel { display: inline-flex; align-items: center; gap: 6px; }
.ampel-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ampel-green { background: var(--success); }
.ampel-yellow { background: var(--warning); }
.ampel-red { background: var(--danger); }
.ampel-gray { background: var(--text-muted); }
.ampel-red.pulse { animation: pulse-red 2s ease-in-out infinite; }
@keyframes pulse-red { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* ---- Progress Bar ---- */
.progress-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ---- Responsive Breakpoints (unified) ---- */
/* Tablet: max-width 1024px */
/* Mobile: max-width 640px */
/* Small:  max-width 400px */
