/**
 * Paper Swing Trader - Dashboard Styles
 * Version: 2.0.0
 */

/* ============================================
   ROOT VARIABLES
   ============================================ */
:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #141b34;
    --bg-tertiary: #1e2746;
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --border-color: #2d3748;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --radius: 12px;
}

.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
}

/* ============================================
   DASHBOARD CONTAINER
   ============================================ */
.paper-trader-dashboard {
    max-width: 1400px;
    margin: 40px auto;
    padding: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ============================================
   HEADER
   ============================================ */
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-header h1 {
    font-size: 2.5rem;
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ============================================
   STRATEGY SELECTOR
   ============================================ */
.strategy-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
    justify-content: center;
}

.strategy-btn {
    padding: 12px 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.strategy-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.strategy-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
    margin-bottom: 40px;
}

.section h2 {
    font-size: 1.8rem;
    margin: 0 0 20px 0;
    color: var(--text-primary);
}

.section h3 {
    font-size: 1.3rem;
    margin: 20px 0 15px 0;
    color: var(--text-secondary);
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.stat-card.loading {
    opacity: 0.6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.stat-change {
    font-size: 0.95rem;
    font-weight: 600;
}

.stat-change.positive {
    color: var(--accent-green);
}

.stat-change.negative {
    color: var(--accent-red);
}

/* ============================================
   METRICS GRID
   ============================================ */
.performance-section {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.metric-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-value.positive {
    color: var(--accent-green);
}

.metric-value.negative {
    color: var(--accent-red);
}

/* ============================================
   CHARTS
   ============================================ */
.chart-container {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.chart-container canvas {
    max-height: 400px;
}

/* ============================================
   TRADES TABLE
   ============================================ */
.trades-section {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.trades-table-container {
    overflow-x: auto;
    margin-top: 15px;
}

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

.trades-table thead {
    background: var(--bg-tertiary);
}

.trades-table th {
    padding: 15px;
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.trades-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.trades-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.trades-table td.loading {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.trade-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.trade-type.long {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.trade-type.short {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.trade-pnl {
    font-weight: 700;
}

.trade-pnl.profit {
    color: var(--accent-green);
}

.trade-pnl.loss {
    color: var(--accent-red);
}

/* ============================================
   LOADING & ERROR STATES
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--accent-red);
    color: var(--accent-red);
    padding: 20px;
    border-radius: var(--radius);
    margin: 20px 0;
    text-align: center;
    font-weight: 600;
}

/* ============================================
   FOOTER
   ============================================ */
.dashboard-footer {
    margin-top: 40px;
    padding: 25px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    text-align: center;
}

.dashboard-footer p {
    margin: 8px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.dashboard-footer strong {
    color: var(--accent-yellow);
}

#last-update {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .dashboard-header h1 {
        font-size: 1.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .strategy-selector {
        flex-direction: column;
    }
    
    .strategy-btn {
        width: 100%;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .trades-table {
        font-size: 0.85rem;
    }
    
    .trades-table th,
    .trades-table td {
        padding: 10px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: slideIn 0.5s ease-out;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-green {
    color: var(--accent-green) !important;
}

.text-red {
    color: var(--accent-red) !important;
}

.text-yellow {
    color: var(--accent-yellow) !important;
}

.text-blue {
    color: var(--accent-blue) !important;
}

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
