/* Dark theme, mobile-first trading dashboard */

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-elevated: #222;
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #00d4aa;
    --positive: #00d4aa;
    --negative: #ff4757;
    --blue: #4a9eff;
    --orange: #ff9f43;
    --nav-height: 60px;
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + 16px);
    -webkit-font-smoothing: antialiased;
}

/* ── Bottom Navigation ─────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: #111;
    border-top: 1px solid #222;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 11px;
    gap: 2px;
    padding: 8px 12px;
    transition: color 0.2s;
}

.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 20px; }

/* ── Page Layout ───────────────────────────────────── */

.page { padding: 16px; max-width: 600px; margin: 0 auto; }

.page-header {
    margin-bottom: 16px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.header-stats {
    color: var(--text-dim);
    font-size: 14px;
}

/* ── Hero ──────────────────────────────────────────── */

.hero {
    text-align: center;
    padding: 24px 0 16px;
}

.hero-label {
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hero-value {
    font-size: 36px;
    font-weight: 800;
    margin: 4px 0;
    font-variant-numeric: tabular-nums;
}

.hero-pnl {
    font-size: 16px;
    font-weight: 600;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

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

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.badge {
    background: var(--bg-elevated);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
}

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

.chart-container {
    height: 300px;
    position: relative;
}

/* ── Lists ─────────────────────────────────────────── */

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #222;
}

.list-item:last-child { border-bottom: none; }

.list-item-left, .list-item-right {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-item-right { align-items: flex-end; }

.symbol {
    font-weight: 700;
    font-size: 15px;
}

.symbol.buy { color: var(--positive); }
.symbol.sell { color: var(--negative); }

.sub {
    font-size: 12px;
    color: var(--text-dim);
}

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
    font-size: 14px;
}

/* ── Tags ──────────────────────────────────────────── */

.tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.tag-signal { background: #1a3a2a; color: var(--positive); }
.tag-stop_loss { background: #3a1a1a; color: var(--negative); }
.tag-take_profit { background: #1a2a3a; color: var(--blue); }
.tag-eod_flatten { background: #2a2a1a; color: var(--orange); }
.tag-stock { background: #1a2a3a; color: var(--blue); }
.tag-crypto { background: #2a1a3a; color: #b366ff; }

/* ── Buttons ───────────────────────────────────────── */

.action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

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

.btn-primary {
    background: var(--accent);
    color: #000;
    flex: 1;
}

.btn-danger {
    background: var(--negative);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Status Messages ───────────────────────────────── */

.status-msg {
    font-size: 13px;
    padding: 8px 0;
    min-height: 20px;
}

.status-msg.info { color: var(--blue); }
.status-msg.success { color: var(--positive); }
.status-msg.error { color: var(--negative); }

/* ── Status Row ────────────────────────────────────── */

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-green { background: var(--positive); }
.dot-red { background: var(--negative); }

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

.position-card .position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.position-body .position-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

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

.sl-tp-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.sl-tp-item {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
}

.sl-tp-item .label {
    display: block;
    font-size: 11px;
    margin-bottom: 2px;
}

.sl-tp-item.sl { background: rgba(255, 71, 87, 0.15); color: var(--negative); }
.sl-tp-item.tp { background: rgba(0, 212, 170, 0.15); color: var(--positive); }

/* ── Tabs ──────────────────────────────────────────── */

.tab-row {
    display: flex;
    gap: 8px;
}

.tab {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid #333;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}

.tab.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ── Trade Detail ──────────────────────────────────── */

.trade-item { cursor: pointer; flex-direction: column; }

.trade-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.trade-detail {
    display: none;
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #222;
}

.trade-detail.show { display: block; }

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 2px 0;
}

.detail-row.reasoning {
    flex-direction: column;
    gap: 4px;
}

.detail-row.reasoning span:last-child {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.4;
}

/* ── Settings ──────────────────────────────────────── */

.add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid #333;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.input:focus { border-color: var(--accent); }

/* ── Bot Log ───────────────────────────────────────── */

.log-container {
    max-height: 400px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.log-time { color: var(--text-dim); white-space: nowrap; }
.log-level { font-weight: 700; width: 40px; flex-shrink: 0; }
.log-msg { word-break: break-word; }

.log-info .log-level { color: var(--blue); }
.log-warn .log-level { color: var(--orange); }
.log-error .log-level { color: var(--negative); }

/* ── Scrollbar ─────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── Performance Stats ────────────────────────────── */

.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-tile {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    min-width: 0;
}

.stat-tile .label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.stat-tile .value {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Time Range Selector ──────────────────────────── */

.time-range {
    display: flex;
    gap: 4px;
}

.range-pill {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #333;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 600;
}

.range-pill.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ── Portfolio Composition ────────────────────────── */

.composition-bar {
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    margin-bottom: 8px;
}

.composition-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 11px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

/* ── Summary Card (What's Happening) ──────────────── */

.summary-card {
    background: rgba(0, 212, 170, 0.06);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 212, 170, 0.15);
}

.summary-card .summary-text {
    font-size: 13px;
    color: #aaa;
    line-height: 1.6;
}

.summary-card .summary-text strong {
    color: var(--accent);
}

.term-tooltip {
    border-bottom: 1px dashed #555;
    cursor: help;
}

.pattern-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 212, 170, 0.1);
}

.pattern-pills:empty { display: none; }

.pattern-pill {
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 600;
}

.pattern-pill.bullish { background: #1a3a2a; color: var(--positive); }
.pattern-pill.bearish { background: #3a1a1a; color: var(--negative); }
.pattern-pill.neutral { background: #2a2a1a; color: var(--orange); }

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

.signal-entry {
    padding: 10px 0;
    border-bottom: 1px solid #222;
}

.signal-entry:last-child { border-bottom: none; }

.signal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.confidence-bar {
    width: 40px;
    height: 4px;
    background: #222;
    border-radius: 2px;
    margin-top: 3px;
}

.confidence-fill {
    height: 100%;
    border-radius: 2px;
}

/* ── Indicator Grid ───────────────────────────────── */

.indicator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.indicator-tile {
    background: var(--bg);
    border-radius: 8px;
    padding: 10px;
}

.indicator-tile .ind-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.indicator-tile .ind-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.indicator-tile .ind-value {
    font-size: 20px;
    font-weight: 700;
}

.indicator-tile .ind-sub {
    font-size: 10px;
    color: var(--text-dim);
}

.help-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-elevated);
    color: #555;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid #333;
}

.tooltip-content {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #222;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    display: none;
}

.tooltip-content.show { display: block; }

/* ── Indicator Position Bar ───────────────────────── */

.ind-bar {
    height: 3px;
    background: #222;
    border-radius: 2px;
    margin-top: 6px;
    position: relative;
}

.ind-bar-fill {
    position: absolute;
    left: 0;
    height: 100%;
    border-radius: 2px;
}

.ind-bar-marker {
    position: absolute;
    top: -2px;
    width: 1px;
    height: 7px;
    background: #555;
}

/* ── Decision History ─────────────────────────────── */

.decision-entry {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid #333;
    cursor: pointer;
}

.decision-entry.buy { border-left-color: var(--positive); }
.decision-entry.sell { border-left-color: var(--negative); }
.decision-entry.hold { border-left-color: var(--orange); }

.decision-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.decision-detail {
    display: none;
    margin-top: 8px;
}

.decision-detail.show { display: block; }

.indicator-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.indicator-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
}

.indicator-pill.bullish { background: #1a2a1a; color: var(--positive); }
.indicator-pill.bearish { background: #3a1a1a; color: var(--negative); }
.indicator-pill.neutral { background: #1a2a3a; color: var(--blue); }

/* ── News Card ────────────────────────────────────── */

.news-list {
    list-style: none;
    padding: 0;
}

.news-item {
    padding: 6px 0;
    border-bottom: 1px solid #1a1a1a;
    font-size: 12px;
    color: #aaa;
    line-height: 1.4;
}

.news-item:last-child { border-bottom: none; }

.news-topic {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-right: 6px;
}

/* ── Symbol Tabs (reusable) ───────────────────────── */

.symbol-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.symbol-tab {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #333;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 600;
}

.symbol-tab.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ── 5-item Nav Adjustment ────────────────────────── */

@media (max-width: 360px) {
    .nav-item {
        padding: 6px 8px;
        font-size: 10px;
    }
    .nav-icon { font-size: 18px; }
}

/* ── Desktop / Large Screens ─────────────────────── */

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
        padding-left: 200px;
    }

    /* Side nav instead of bottom nav */
    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 200px;
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        padding: 24px 0;
        border-top: none;
        border-right: 1px solid #222;
    }

    .nav-item {
        flex-direction: row;
        gap: 10px;
        padding: 12px 24px;
        font-size: 13px;
        width: 100%;
        justify-content: flex-start;
        border-radius: 0;
    }

    .nav-item.active {
        background: rgba(0, 212, 170, 0.08);
        border-right: 2px solid var(--accent);
    }

    .nav-icon { font-size: 18px; }

    .page {
        max-width: 1000px;
        padding: 24px 32px;
    }

    .page-header h2 { font-size: 26px; }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .stat-tile {
        padding: 14px;
    }

    .stat-tile .value { font-size: 18px; }

    /* Wider chart */
    .chart-container { height: 350px; }

    /* 3-col indicator grid on desktop */
    .indicator-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 12px;
    }

    .indicator-tile .ind-value { font-size: 22px; }

    /* Position cards side by side */
    #positions-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 12px;
    }

    #positions-cards .card { margin-bottom: 0; }

    /* Trade details wider */
    .detail-row {
        font-size: 14px;
    }

    /* Log container taller */
    .log-container { max-height: 500px; }

    /* Hero larger */
    .hero-value { font-size: 48px; }
    .hero-pnl { font-size: 18px; }

    /* Action row doesn't stretch full width */
    .action-row {
        max-width: 400px;
    }

    .btn-primary { flex: none; }
}

/* ── Extra-wide (1200px+) ────────────────────────── */

@media (min-width: 1200px) {
    body { padding-left: 220px; }

    .bottom-nav { width: 220px; }

    .nav-item {
        padding: 14px 28px;
        font-size: 14px;
    }

    .page {
        max-width: 1200px;
        padding: 32px 48px;
    }

    .stats-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 16px;
    }

    .stat-tile .label { font-size: 11px; }
    .stat-tile .value { font-size: 20px; }

    .chart-container { height: 400px; }

    /* Dashboard two-column layout */
    .dashboard-grid {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 16px;
    }
}
