/* ─── AlgoTrader Scanner — Dark Theme ─────────────────────────────── */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2333;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --orange: #db6d28;
    --purple: #a371f7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
}

/* ─── Navbar ──────────────────────────────────────────────────────── */

.navbar {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
    margin-right: 32px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 14px 16px;
    display: inline-block;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* ─── Container ───────────────────────────────────────────────────── */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

h1 { font-size: 24px; margin-bottom: 20px; }
h2 { font-size: 18px; margin: 24px 0 12px; color: var(--text-secondary); }

/* ─── Cards ───────────────────────────────────────────────────────── */

.scan-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    min-width: 160px;
    flex: 1;
}

.card-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.card-value {
    font-size: 20px;
    font-weight: 600;
}

.card-value.small { font-size: 14px; }

/* ─── Tables ──────────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.data-table thead {
    background: var(--bg-card);
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: rgba(88, 166, 255, 0.05);
}

.data-table.compact th,
.data-table.compact td {
    padding: 6px 10px;
    font-size: 13px;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

.symbol a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.symbol a:hover { text-decoration: underline; }

tr.up td:nth-child(5) { color: var(--green); }
tr.down td:nth-child(5) { color: var(--red); }

/* ─── Badges & Tags ──────────────────────────────────────────────── */

.badge {
    display: inline-block;
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin: 2px;
}

.badge.small { font-size: 11px; padding: 1px 6px; }

.signal-tag {
    display: inline-block;
    background: rgba(163, 113, 247, 0.15);
    color: var(--purple);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin: 1px 2px;
}

/* ─── Regime ──────────────────────────────────────────────────────── */

.regime-bullish { color: var(--green); }
.regime-sideways { color: var(--yellow); }
.regime-bearish { color: var(--red); }

/* ─── Conviction ──────────────────────────────────────────────────── */

.conviction {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.conviction-high { background: rgba(63, 185, 80, 0.2); color: var(--green); }
.conviction-medium { background: rgba(210, 153, 34, 0.2); color: var(--yellow); }
.conviction-standard { background: rgba(139, 148, 158, 0.2); color: var(--text-secondary); }

/* ─── OI Stance ───────────────────────────────────────────────────── */

.oi-stance { font-size: 11px; }
.oi-long_buildup { color: var(--green); }
.oi-short_covering { color: var(--yellow); }
.oi-short_buildup { color: var(--red); }
.oi-long_unwinding { color: var(--orange); }
.oi-no_data, .oi-neutral { color: var(--text-secondary); }

.oi-surge {
    display: inline-block;
    background: var(--orange);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

/* ─── Controls ────────────────────────────────────────────────────── */

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls label {
    color: var(--text-secondary);
    font-size: 13px;
}

select, input[type="date"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

select { min-width: 180px; }

.btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

/* ─── Scan Blocks (Signals page) ──────────────────────────────────── */

.scan-block {
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.scan-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.scan-time { font-weight: 600; }
.scan-empty { padding: 16px; }

/* ─── Chart Container ─────────────────────────────────────────────── */

#chart-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #1a1a2e;
}

/* ─── Actions ─────────────────────────────────────────────────────── */

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ─── Empty State ─────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h2 { color: var(--text-primary); margin-bottom: 8px; }

.muted { color: var(--text-secondary); }
.error { color: var(--red); }

/* ─── Recommendations / Portfolio ─────────────────────────────── */
.portfolio-snapshot {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 14px 16px;
    background: var(--surface, #1e1e26);
    border-radius: 6px;
    margin-bottom: 20px;
}
.portfolio-snapshot .kv {
    display: flex;
    flex-direction: column;
    font-size: 13px;
}
.portfolio-snapshot .kv span { color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.portfolio-snapshot .kv strong { font-size: 16px; color: var(--text-primary); margin-top: 2px; }

.inline-form { display: inline-flex; gap: 4px; align-items: center; margin-right: 6px; }
.inline-form input, .inline-form select {
    padding: 3px 6px; font-size: 12px; border: 1px solid #444;
    background: #14141a; color: var(--text-primary); border-radius: 3px;
}
.actions { white-space: nowrap; }

.btn-danger {
    background: #7a2f2f; color: #fff; padding: 4px 10px;
    border: 0; border-radius: 3px; font-size: 12px; cursor: pointer;
}
.btn-danger:hover { background: #9a3a3a; }

.pnl-positive { color: #4caf50; font-weight: 600; }
.pnl-negative { color: #e57373; font-weight: 600; }

.status-executed { color: #4caf50; }
.status-rejected { color: #e57373; }
.status-expired  { color: #8a8a8a; }

.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 8px 12px; border-radius: 4px; margin-bottom: 6px; font-size: 13px; }
.messages .msg-success { background: #224b22; color: #c9eccb; }
.messages .msg-error   { background: #4b2222; color: #eccbcb; }
.messages .msg-info    { background: #22334b; color: #cbd9ec; }

/* ─── Kite status badge ─────────────────────────────────────────── */
.nav-kite { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.kite-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
}
.kite-ok  { background: #1b3a1f; color: #7ee08a; border: 1px solid #2d5a33; }
.kite-bad { background: #3a1b1b; color: #f08a8a; border: 1px solid #5a2d2d; }
.kite-refresh {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 2px 6px;
}
.kite-refresh:hover { color: var(--accent); }
