/* Mobile-first responsive dashboard */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #131825;
    --bg-card: #1a1f2e;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --accent: #4f88ff;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --border: #2a2f3e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.mode-badge {
    display: inline-block;
    background: var(--warning);
    color: #000;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Portfolio Summary */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Chart Section */
.chart-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.chart-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#portfolio-chart {
    max-height: 300px;
}

/* Sections */
section {
    margin-bottom: 1.5rem;
}

section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.count-badge {
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}

/* Positions */
.positions-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.positions-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.position-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.position-title {
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
    margin-right: 0.5rem;
}

.position-side {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
}

.position-side.yes {
    background: rgba(52, 199, 89, 0.2);
    color: var(--success);
}

.position-side.no {
    background: rgba(255, 59, 48, 0.2);
    color: var(--danger);
}

.position-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.85rem;
}

.position-detail {
    display: flex;
    justify-content: space-between;
}

.position-detail label {
    color: var(--text-secondary);
}

.position-pnl {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.position-pnl.positive { color: var(--success); }
.position-pnl.negative { color: var(--danger); }

/* Trade History */
.trades-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.trades-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.trades-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trades-table thead th {
    text-align: left;
    padding: 0.7rem 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.trades-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.trades-table tbody tr:hover {
    background: rgba(79, 136, 255, 0.05);
}

.trades-table td {
    padding: 0.7rem 0.5rem;
    white-space: nowrap;
}

.trade-date {
    font-weight: 600;
    font-size: 0.85rem;
}

.trade-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trade-market-cell {
    max-width: 200px;
    white-space: normal !important;
    word-wrap: break-word;
    line-height: 1.3;
}

.trade-side {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: bold;
}

.trade-side.buy-yes {
    background: rgba(52, 199, 89, 0.2);
    color: var(--success);
}

.trade-side.buy-no {
    background: rgba(255, 59, 48, 0.2);
    color: var(--danger);
}

.trade-status {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.trade-status.filled {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.trade-status.pending {
    background: rgba(255, 149, 0, 0.15);
    color: var(--warning);
}

td.positive { color: var(--success); font-weight: 600; }
td.negative { color: var(--danger); font-weight: 600; }

/* Metrics */
.metrics-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.metric-card {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: bold;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* Navigation */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    position: absolute;
    left: 1rem;
}

.nav-link:hover {
    text-decoration: underline;
}

.view-all-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: normal;
    margin-left: auto;
}

.view-all-link:hover {
    text-decoration: underline;
}

/* Order type badges */
.order-type {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.order-type.maker {
    background: rgba(79, 136, 255, 0.15);
    color: var(--accent);
}

.order-type.taker {
    background: rgba(255, 149, 0, 0.15);
    color: var(--warning);
}

.trade-status.expired {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.trade-id {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.filter-section {
    margin-bottom: 0;
}

header {
    position: relative;
}

/* Responsive */
@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .portfolio-summary {
        grid-template-columns: repeat(4, 1fr);
    }

    #portfolio-chart {
        max-height: 400px;
    }
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .position-details {
        grid-template-columns: 1fr;
    }
    
    .trades-table {
        font-size: 0.78rem;
    }
    
    .trades-table td, .trades-table th {
        padding: 0.5rem 0.3rem;
    }
    
    .trade-market-cell {
        max-width: 120px;
    }
}
