/* ============================================
   WEYD Panel Theme System - Dark/Light Mode
   ============================================ */

/* Dark Theme (Default) */
:root {
    /* Primary Colors */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-hover: #5558e3;
    --primary-100: rgba(99, 102, 241, 0.15);
    --primary-glow: rgba(99, 102, 241, 0.4);

    /* Secondary & Accent */
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.3);

    /* Status Colors */
    --success-color: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --success-border: rgba(34, 197, 94, 0.3);
    --warning-color: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: rgba(245, 158, 11, 0.3);
    --danger-color: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.3);
    --info-color: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --info-border: rgba(59, 130, 246, 0.3);

    /* Background Colors */
    --bg-body: #0f0f14;
    --bg-dark: #121218;
    --bg-darker: #0a0a0f;
    --bg-surface: #1a1a24;
    --bg-surface-hover: #22222e;
    --bg-surface-variant: #252532;
    --bg-card: rgba(26, 26, 36, 0.8);
    --bg-card-hover: rgba(34, 34, 46, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(15, 15, 20, 0.9);

    /* Text Colors */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.45);
    --text-disabled: rgba(255, 255, 255, 0.25);
    --text-inverse: #0f0f14;

    /* Border Colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(99, 102, 241, 0.5);
    --divider: rgba(255, 255, 255, 0.06);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-surface: linear-gradient(145deg, rgba(26, 26, 36, 0.9) 0%, rgba(15, 15, 21, 0.95) 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    --gradient-text: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);

    /* Chart Colors */
    --chart-1: #6366f1;
    --chart-2: #22c55e;
    --chart-3: #f59e0b;
    --chart-4: #ef4444;
    --chart-5: #8b5cf6;
    --chart-6: #06b6d4;
    --chart-7: #ec4899;
    --chart-8: #10b981;

    /* Misc */
    --backdrop-blur: blur(20px);
    --border-radius-sm: 6px;
    --border-radius: 10px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --transition-fast: 150ms ease;
    --transition: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Light Theme */
[data-theme="light"] {
    /* Primary Colors - slightly adjusted for light mode */
    --primary-color: #5558e3;
    --primary-light: #7377f5;
    --primary-dark: #4338ca;
    --primary-hover: #4f46e5;
    --primary-100: rgba(99, 102, 241, 0.12);
    --primary-glow: rgba(99, 102, 241, 0.25);

    /* Secondary & Accent */
    --secondary-color: #7c3aed;
    --accent-color: #0891b2;
    --accent-glow: rgba(8, 145, 178, 0.2);

    /* Status Colors */
    --success-color: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.1);
    --success-border: rgba(22, 163, 74, 0.25);
    --warning-color: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --warning-border: rgba(217, 119, 6, 0.25);
    --danger-color: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --danger-border: rgba(220, 38, 38, 0.25);
    --info-color: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.1);
    --info-border: rgba(37, 99, 235, 0.25);

    /* Background Colors */
    --bg-body: #f8fafc;
    --bg-dark: #f1f5f9;
    --bg-darker: #e2e8f0;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-surface-variant: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-hover: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-disabled: #cbd5e1;
    --text-inverse: #ffffff;

    /* Border Colors */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.12);
    --border-focus: rgba(99, 102, 241, 0.5);
    --divider: rgba(0, 0, 0, 0.06);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #5558e3 0%, #7c3aed 100%);
    --gradient-success: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    --gradient-danger: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    --gradient-surface: linear-gradient(145deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 1) 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
    --gradient-text: linear-gradient(135deg, #1e293b 0%, #475569 100%);

    /* Chart Colors - slightly muted for light mode */
    --chart-1: #5558e3;
    --chart-2: #16a34a;
    --chart-3: #d97706;
    --chart-4: #dc2626;
    --chart-5: #7c3aed;
    --chart-6: #0891b2;
    --chart-7: #db2777;
    --chart-8: #059669;
}

/* Theme Transition */
body,
body * {
    transition: background-color var(--transition),
                border-color var(--transition),
                box-shadow var(--transition);
}

/* ============================================
   Theme Toggle Button
   ============================================ */
.theme-toggle {
    position: relative;
    width: 56px;
    height: 28px;
    background: var(--bg-surface-variant);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    padding: 2px;
}

.theme-toggle:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.theme-toggle-slider {
    position: absolute;
    width: 22px;
    height: 22px;
    background: var(--gradient-primary);
    border-radius: 50%;
    transition: transform var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    left: 3px;
}

[data-theme="light"] .theme-toggle-slider {
    transform: translateX(26px);
    background: var(--gradient-warning);
}

.theme-toggle-icon {
    width: 14px;
    height: 14px;
    color: white;
}

.theme-toggle-icon.sun {
    display: none;
}

.theme-toggle-icon.moon {
    display: block;
}

[data-theme="light"] .theme-toggle-icon.sun {
    display: block;
}

[data-theme="light"] .theme-toggle-icon.moon {
    display: none;
}

/* ============================================
   Stat Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--gradient-surface);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.success::before { background: var(--gradient-success); opacity: 1; }
.stat-card.warning::before { background: var(--gradient-warning); opacity: 1; }
.stat-card.danger::before { background: var(--gradient-danger); opacity: 1; }
.stat-card.primary::before { background: var(--gradient-primary); opacity: 1; }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-100);
    color: var(--primary-color);
}

.stat-card.success .stat-card-icon { background: var(--success-bg); color: var(--success-color); }
.stat-card.warning .stat-card-icon { background: var(--warning-bg); color: var(--warning-color); }
.stat-card.danger .stat-card-icon { background: var(--danger-bg); color: var(--danger-color); }

.stat-card-change {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card-change.positive {
    background: var(--success-bg);
    color: var(--success-color);
}

.stat-card-change.negative {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.stat-card-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--divider);
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================
   Chart Cards
   ============================================ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    background: var(--gradient-surface);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    transition: all var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-card-title-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-100);
    color: var(--primary-color);
    font-size: 16px;
}

.chart-card-actions {
    display: flex;
    gap: 8px;
}

.chart-period-btn {
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chart-period-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.chart-period-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container.small {
    height: 200px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--divider);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ============================================
   Analytics Page Specific
   ============================================ */
.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
}

.analytics-title {
    font-size: 32px;
    font-weight: 700;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.analytics-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-range-picker:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
}

/* Quick Stats Row */
.quick-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.quick-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
}

.quick-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.quick-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.quick-stat-label {
    color: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card-value {
        font-size: 28px;
    }

    .stat-card-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-card {
        padding: 16px;
    }

    .chart-container {
        height: 220px;
    }

    .analytics-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .analytics-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .quick-stats {
        flex-direction: column;
    }

    .quick-stat {
        justify-content: space-between;
    }
}
