/* ─── Global Variables & Reset ───────────────────────────────────────── */
:root {
    /* LIGHT THEME (Human Designed Default) */
    --bg-primary: #f4f6f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-default: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --chart-grid: rgba(0, 0, 0, 0.05);
    
    --accent-indigo: #4f46e5;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    
    --gradient-primary: linear-gradient(135deg, var(--accent-indigo), #8b5cf6);
    --shadow-glow: 0 4px 14px rgba(79, 70, 229, 0.3);
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* DARK THEME */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-default: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --chart-grid: rgba(255, 255, 255, 0.05);
    
    --accent-indigo: #6366f1;
    
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.4);
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 2rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

svg {
    transition: var(--transition);
}

/* ─── Header ──────────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-badge {
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-emerald);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ─── Theme Toggle Button ────────────────────────────────────────── */
.theme-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* ─── Filter Bar ────────────────────────────────────────────────── */
.filter-bar {
    position: relative;
    z-index: 99;
    max-width: 1800px;
    margin: 24px auto 0;
    padding: 16px 32px;
    display: flex;
    align-items: flex-end;
    gap: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-left: 32px;
    margin-right: 32px;
    box-shadow: var(--shadow-default);
    transition: var(--transition);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    max-width: 200px;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

[data-theme="dark"] .filter-select {
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.filter-select:hover, .filter-select:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.filter-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.filter-btn {
    padding: 11px 24px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    height: 42px;
}

.filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.filter-btn:active {
    transform: translateY(1px);
}

/* ─── Main Content ────────────────────────────────────────────── */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1800px;
    margin: 0 auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ─── KPI Section ─────────────────────────────────────────────── */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: var(--transition);
    box-shadow: var(--shadow-default);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Colored Top Border for KPIs */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-indigo);
    opacity: 0;
    transition: var(--transition);
}

.kpi-card:hover::before {
    opacity: 1;
}

#kpi-revenue::before { background: var(--accent-indigo); }
#kpi-orders::before { background: var(--accent-cyan); }
#kpi-customers::before { background: var(--accent-emerald); }
#kpi-avg-order::before { background: var(--accent-emerald); }
#kpi-review::before { background: var(--accent-rose); }
#kpi-delivery::before { background: var(--accent-cyan); }

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.revenue-icon { background: rgba(79, 70, 229, 0.1); color: var(--accent-indigo); }
.orders-icon { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }
.customers-icon { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.avg-icon { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.review-icon { background: rgba(244, 63, 94, 0.1); color: var(--accent-rose); }
.delivery-icon { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }

.kpi-content {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Charts Grid ─────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(auto, auto);
    gap: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-hover);
}

.chart-wide {
    grid-column: span 8;
}

.chart-narrow {
    grid-column: span 4;
}

.chart-half {
    grid-column: span 6;
}

.chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-legend {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.chart-body {
    padding: 20px;
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-body-tall {
    height: 380px;
}

/* ─── Footer ──────────────────────────────────────────────────── */
.footer {
    padding: 48px 32px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    background: var(--bg-card);
}

.footer-content {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-project-info p {
    font-size: 0.85rem;
}

.footer-sub {
    font-size: 0.75rem !important;
    opacity: 0.7;
    margin-top: 4px;
}

.footer-contact {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.developer-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.contact-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
}

.contact-link:hover {
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
    background: rgba(79, 70, 229, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

/* ─── Responsive ──────────────────────────────────────────────── */
/* 1. Laptops & Large Tablets (1024px - 1400px) */
@media (max-width: 1400px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-wide, .chart-narrow {
        grid-column: span 2; /* wide & narrow wrap to full width rows */
    }
    .chart-half {
        grid-column: span 1; /* side-by-side */
    }
    .kpi-section {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 2. Tablets (768px - 1023px) */
@media (max-width: 1023px) {
    .charts-grid {
        grid-template-columns: 1fr; /* All charts single column */
    }
    .chart-wide, .chart-narrow, .chart-half {
        grid-column: span 1;
    }
    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 3. Mobile Devices (max-width: 767px) */
@media (max-width: 767px) {
    .header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
        padding: 20px;
    }
    .main-content {
        padding: 16px;
    }
    .kpi-section {
        grid-template-columns: 1fr; /* KPI cards stack */
    }
    .chart-body {
        height: 250px;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        margin-left: 16px;
        margin-right: 16px;
        padding: 16px;
    }
    .filter-group {
        max-width: none;
    }
    .footer {
        padding: 32px 20px;
    }
    .footer-content {
        flex-direction: column;
        align-items: flex-start;
    }
    .footer-contact {
        align-items: flex-start;
        margin-top: 16px;
    }
    .contact-links {
        justify-content: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}
