/* CapitalPilot Assistant — Fintech Dashboard Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Core Palette — Deep Navy + Electric Teal */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1f2847;
    --bg-input: #0f1629;
    --bg-sidebar: #070b14;

    --border: #1e2a45;
    --border-focus: #00d4aa;
    --border-subtle: #162033;

    --text-primary: #e8edf5;
    --text-secondary: #8899b4;
    --text-muted: #556480;
    --text-heading: #f0f4fa;

    --accent: #00d4aa;
    --accent-hover: #00eabc;
    --accent-dim: rgba(0,212,170,0.12);
    --accent-glow: rgba(0,212,170,0.25);

    --profit: #00e68a;
    --profit-bg: rgba(0,230,138,0.1);
    --loss: #ff4d6a;
    --loss-bg: rgba(255,77,106,0.1);
    --warn: #ffb830;
    --warn-bg: rgba(255,184,48,0.1);
    --info: #3b82f6;
    --info-bg: rgba(59,130,246,0.1);

    --buy: #00d4aa;
    --sell: #ff4d6a;
    --hold: #ffb830;

    --sidebar-w: 260px;
    --topbar-h: 60px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --transition: 0.2s ease;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f4f9;
    --bg-input: #f5f7fb;
    --bg-sidebar: #0f1629;
    --border: #e2e8f0;
    --border-focus: #00b894;
    --border-subtle: #edf0f5;
    --text-primary: #1a2035;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-heading: #0f172a;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #0099ff);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px; color: #fff;
}
.sidebar-brand { font-weight: 700; font-size: 16px; color: var(--text-heading); letter-spacing: -0.3px; }
.sidebar-brand small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 24px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 24px; color: var(--text-secondary);
    font-size: 13px; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); }
.nav-link .icon { width: 18px; text-align: center; font-size: 15px; opacity: 0.8; }
.nav-link .badge-count {
    margin-left: auto; background: var(--loss); color: #fff;
    font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}
.sidebar-footer { padding: 16px 24px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-info .name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sidebar-user-info .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h); background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-heading); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-live { display:flex; align-items:center; gap:6px; padding:4px 12px; border-radius:20px; background:rgba(0,212,170,0.08); border:1px solid rgba(0,212,170,0.2); }
.live-dot { width:7px; height:7px; border-radius:50%; display:inline-block; }
.live-dot-on { background:#00d4aa; box-shadow:0 0 6px rgba(0,212,170,0.6); animation:livePulse 2s ease-in-out infinite; }
.live-dot-off { background:#ff4757; }
.live-time { font-size:11px; font-weight:600; color:var(--text-muted); font-family:var(--font-mono); }
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.sidebar-user a.name:hover { color:var(--text-accent) !important; }
.sidebar-user a.sidebar-avatar:hover { opacity:0.8; }
.topbar-btn {
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 13px; transition: all var(--transition); display: flex; align-items: center; gap: 6px;
}
.topbar-btn:hover { border-color: var(--accent); color: var(--accent); }
.notification-dot {
    width: 8px; height: 8px; background: var(--loss); border-radius: 50%;
    position: absolute; top: -2px; right: -2px;
}

.page-content { flex: 1; padding: 28px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-focus); }
.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-heading); }
.card-body { padding: 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.1); }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
}
.stat-card.profit::before { background: linear-gradient(90deg, var(--profit), transparent); }
.stat-card.loss::before { background: linear-gradient(90deg, var(--loss), transparent); }
.stat-card.warn::before { background: linear-gradient(90deg, var(--warn), transparent); }
.stat-card.info::before { background: linear-gradient(90deg, var(--info), transparent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-heading); margin: 4px 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: 0.5px; }
.stat-change { font-size: 12px; font-weight: 600; }
.stat-change.up { color: var(--profit); }
.stat-change.down { color: var(--loss); }
.stat-icon { position: absolute; top: 18px; right: 20px; font-size: 28px; opacity: 0.15; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-muted); font-weight: 600;
    border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.15);
    white-space: nowrap;
}
tbody td {
    padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary); vertical-align: middle;
}
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }
td.mono { font-family: var(--font-mono); font-size: 12px; }
td.profit { color: var(--profit); font-weight: 600; }
td.loss { color: var(--loss); font-weight: 600; }
td.symbol-name { color: var(--text-heading); font-weight: 600; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-profit { background: var(--profit-bg); color: var(--profit); }
.badge-loss { background: var(--loss-bg); color: var(--loss); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: rgba(136,153,180,0.12); color: var(--text-secondary); }
.badge-buy { background: rgba(0,212,170,0.15); color: var(--buy); }
.badge-sell { background: rgba(255,77,106,0.15); color: var(--sell); }
.badge-hold { background: rgba(255,184,48,0.15); color: var(--hold); }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 13px; font-family: var(--font-sans);
    transition: all var(--transition); outline: none;
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23556480' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.form-check input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.form-check label { font-size: 13px; color: var(--text-secondary); cursor: pointer; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 600; cursor: pointer; border: none; transition: all var(--transition);
    font-family: var(--font-sans); text-decoration: none; line-height: 1.4;
}
.btn-primary { background: var(--accent); color: #0a0e1a; }
.btn-primary:hover { background: var(--accent-hover); color: #0a0e1a; box-shadow: 0 4px 15px var(--accent-glow); }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--loss); color: #fff; }
.btn-danger:hover { background: #ff2d50; }
.btn-success { background: var(--profit); color: #0a0e1a; }
.btn-warning { background: var(--warn); color: #0a0e1a; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; }

/* Alerts / Flash Messages */
.alert {
    padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 18px;
    font-size: 13px; display: flex; align-items: center; gap: 10px;
    border: 1px solid;
}
.alert-success { background: var(--profit-bg); border-color: rgba(0,230,138,0.2); color: var(--profit); }
.alert-error { background: var(--loss-bg); border-color: rgba(255,77,106,0.2); color: var(--loss); }
.alert-warning { background: var(--warn-bg); border-color: rgba(255,184,48,0.2); color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: rgba(59,130,246,0.2); color: var(--info); }

/* Disclaimer */
.disclaimer {
    background: var(--warn-bg); border: 1px solid rgba(255,184,48,0.2);
    border-radius: var(--radius-sm); padding: 14px 18px; font-size: 12px;
    color: var(--warn); line-height: 1.7; margin-bottom: 18px;
}
.disclaimer strong { color: var(--warn); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab-link {
    padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; cursor: pointer; transition: all var(--transition);
    background: none; border-top: none; border-left: none; border-right: none;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Scenarios */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.scenario-card {
    padding: 18px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-card);
}
.scenario-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.scenario-card .value { font-family: var(--font-mono); font-size: 18px; font-weight: 700; }

/* Signal Score Gauge */
.signal-score {
    width: 80px; height: 80px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 800; font-family: var(--font-mono);
    border: 4px solid;
}
.signal-score.buy { border-color: var(--buy); color: var(--buy); background: rgba(0,212,170,0.08); }
.signal-score.sell { border-color: var(--sell); color: var(--sell); background: rgba(255,77,106,0.08); }
.signal-score.hold { border-color: var(--hold); color: var(--hold); background: rgba(255,184,48,0.08); }

/* Chart Container */
.chart-container { position: relative; width: 100%; height: 300px; margin: 16px 0; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* AI Chat */
.chat-container { display: flex; height: calc(100vh - var(--topbar-h) - 56px); }
.chat-sidebar { width: 260px; border-right: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; }
.chat-message { margin-bottom: 16px; display: flex; gap: 12px; }
.chat-message.user { flex-direction: row-reverse; }
.chat-bubble {
    max-width: 70%; padding: 12px 16px; border-radius: 12px;
    font-size: 13px; line-height: 1.6;
}
.chat-message.assistant .chat-bubble { background: var(--bg-card); border: 1px solid var(--border); }
.chat-message.user .chat-bubble { background: var(--accent-dim); border: 1px solid rgba(0,212,170,0.2); }
.chat-input-area {
    padding: 16px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; background: var(--bg-secondary);
}
.chat-input-area input { flex: 1; }

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 20% 50%, rgba(0,212,170,0.05) 0%, transparent 50%),
                      radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.05) 0%, transparent 50%);
}
.auth-card {
    width: 420px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow);
}
.auth-card .logo { text-align: center; margin-bottom: 32px; }
.auth-card .logo-icon {
    width: 56px; height: 56px; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 800; color: #fff;
}
.auth-card h1 { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 8px; color: var(--text-heading); }
.auth-card p.subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Mobile Toggle */
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 22px; cursor: pointer; padding: 8px; }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .form-row { grid-template-columns: 1fr; }
    .chat-sidebar { display: none; }
}
@media (max-width: 640px) {
    .page-content { padding: 16px; }
    .card-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 20px; }
    .auth-card { width: 100%; margin: 16px; padding: 28px; }
}

/* Utility */
.text-profit { color: var(--profit); }
.text-loss { color: var(--loss); }
.text-warn { color: var(--warn); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fs-sm { font-size: 12px; }
.fs-lg { font-size: 18px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.mr-1 { margin-right: 8px; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.overflow-auto { overflow: auto; }

/* Loading spinner */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page header */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--text-heading); margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--text-muted); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .icon { font-size: 48px; opacity: 0.2; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
    padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px;
    border: 1px solid var(--border); color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: #0a0e1a; border-color: var(--accent); font-weight: 700; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 500px; max-width: 90vw;
    max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
