/* ── Dark theme (default) ── */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --warning: #facc15;
    --danger: #ef4444;
    --border: #334155;
    --glass: rgba(30, 41, 59, 0.7);
    --th-bg: rgba(30, 41, 59, 0.8);
    --td-hover: rgba(255, 255, 255, 0.02);
    --td-border: rgba(255, 255, 255, 0.05);
    --gradient-a: rgba(99, 102, 241, 0.15);
    --gradient-b: rgba(168, 85, 247, 0.15);
    --h2-color: #e2e8f0;
    --header-border: rgba(255, 255, 255, 0.05);
}

/* ── Light theme ── */
[data-theme="light"] {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --border: #cbd5e1;
    --glass: rgba(255, 255, 255, 0.8);
    --th-bg: rgba(241, 245, 249, 0.95);
    --td-hover: rgba(0, 0, 0, 0.02);
    --td-border: rgba(0, 0, 0, 0.06);
    --gradient-a: rgba(99, 102, 241, 0.08);
    --gradient-b: rgba(168, 85, 247, 0.08);
    --h2-color: #1e293b;
    --header-border: rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    background-image: 
        radial-gradient(circle at top right, var(--gradient-a), transparent 40%),
        radial-gradient(circle at bottom left, var(--gradient-b), transparent 40%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--header-border);
}

.header-left h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.header-left .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.status-badge {
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.overview {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease,
                background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.main-nps-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card h3, .main-nps-card h3 {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.nps-display {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.stat-value {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}

.nps-category {
    font-weight: 600;
    font-size: 1.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
}

/* Dynamic NPS Colors */
.nps-excellent { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.nps-good { color: #facc15; background: rgba(250, 204, 21, 0.1); }
.nps-needs-improvement { color: #fb923c; background: rgba(251, 146, 60, 0.1); }
.nps-poor { color: #f87171; background: rgba(248, 113, 113, 0.1); }

.nps-breakdown {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.breakdown-item {
    display: flex;
    flex-direction: column;
}

.breakdown-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.breakdown-item .val {
    font-size: 1.25rem;
    font-weight: 600;
}

.breakdown-item.promoter .val { color: var(--success); }
.breakdown-item.passive .val { color: var(--warning); }
.breakdown-item.detractor .val { color: var(--danger); }

.chart-container {
    height: 120px;
    width: 100%;
    margin-top: 1rem;
    position: relative;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.grid-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--h2-color);
}

.table-container {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--th-bg);
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--td-border);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--td-hover);
}

.rating-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-block;
    text-align: center;
    min-width: 60px;
}

.rating-high { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.rating-mid { background: rgba(250, 204, 21, 0.15); color: #facc15; border: 1px solid rgba(250, 204, 21, 0.3); }
.rating-low { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Icons & Typography Enhancements */
i.ph, i.ph-fill {
    vertical-align: text-bottom;
    margin-right: 0.25rem;
}

h2 i.ph {
    color: var(--primary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.stagger-1 { animation: fadeIn 0.5s ease-out 0.1s both; }
.stagger-2 { animation: fadeIn 0.5s ease-out 0.2s both; }
.stagger-3 { animation: fadeIn 0.5s ease-out 0.3s both; }
.stagger-4 { animation: fadeIn 0.5s ease-out 0.4s both; }

/* ── Theme Toggle Button ── */
.theme-toggle {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 9999px;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.75rem;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: rotate(20deg) scale(1.1);
}

.theme-toggle .icon-moon { display: inline; }
.theme-toggle .icon-sun  { display: none;   }

[data-theme="light"] .theme-toggle .icon-moon { display: none;   }
[data-theme="light"] .theme-toggle .icon-sun  { display: inline; }

/* Smooth theme transition */
body, .table-container, header, th, td {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ── Responsive Adjustments ── */
@media (max-width: 1024px) {
    .overview, .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
