/* ═══════════════════════════════════════════════════════════════════════════
   SMARPRDC Statistics Dashboard — Inspired by eSchoolStructure
   Light theme with indigo accents, hero cards, collapsible sections
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
    --bg-body:          #f0f2f5;
    --bg-card:          #ffffff;
    --bg-header:        linear-gradient(135deg, #0f172a, #1e293b);

    --border-light:     #e5e7eb;
    --border-indigo:    #c7d2fe;

    --text-primary:     #1e293b;
    --text-secondary:   #475569;
    --text-muted:       #94a3b8;

    --accent-indigo:    #6366f1;
    --accent-violet:    #8b5cf6;
    --accent-blue:      #3b82f6;
    --accent-pink:      #ec4899;
    --accent-emerald:   #10b981;
    --accent-teal:      #0d9488;
    --accent-amber:     #f59e0b;
    --accent-red:       #ef4444;
    --accent-cyan:      #06b6d4;
    --accent-sky:       #0ea5e9;

    --shadow-sm:        0 1px 3px rgba(0,0,0,0.06);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:        0 6px 30px rgba(0,0,0,0.12);
    --shadow-card:      0 2px 12px rgba(0,0,0,0.04);

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  14px;

    --transition: 0.2s ease;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
    background: var(--bg-header);
    border-bottom: 2px solid rgba(99,102,241,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1500px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: white;
    box-shadow: 0 0 20px rgba(99,102,241,.3);
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,.5);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 1px;
}

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

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(99,102,241,.15);
    border: 1px solid rgba(99,102,241,.25);
    font-size: 12px;
    font-weight: 500;
    color: #a5b4fc;
    transition: var(--transition);
}

.pulse-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%,100% { opacity:1; transform:scale(1); }
    50%     { opacity:0.4; transform:scale(0.7); }
}

/* ── Main Container ───────────────────────────────────────────────────────── */
.main-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ── Hero KPI Cards (eSchoolStructure style) ──────────────────────────────── */
.stats-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.hero-card {
    background: linear-gradient(135deg, var(--bg1), var(--bg2));
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow-color);
    transition: transform var(--transition);
    cursor: default;
}

.hero-card:hover { transform: translateY(-3px); }

.hero-card .icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.15;
}

.hero-card .label {
    font-size: .68rem;
    opacity: .85;
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 600;
}

.hero-card .value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 2px;
}

.hero-card .sub {
    font-size: .64rem;
    opacity: .7;
    margin-top: 4px;
}

.hero-card .gender-split {
    display: flex;
    gap: 5px;
    margin-top: 6px;
    font-size: .64rem;
    opacity: .9;
}

.hero-card .gender-split span {
    background: rgba(255,255,255,.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.hero-card.c1 { --bg1:#667eea; --bg2:#764ba2; --shadow-color:rgba(102,126,234,.3); }
.hero-card.c2 { --bg1:#0d9488; --bg2:#2dd4bf; --shadow-color:rgba(13,148,136,.3); }
.hero-card.c3 { --bg1:#f59e0b; --bg2:#f97316; --shadow-color:rgba(245,158,11,.3); }
.hero-card.c4 { --bg1:#ef4444; --bg2:#f97316; --shadow-color:rgba(239,68,68,.3); }
.hero-card.c5 { --bg1:#8b5cf6; --bg2:#a78bfa; --shadow-color:rgba(139,92,246,.3); }
.hero-card.c6 { --bg1:#06b6d4; --bg2:#22d3ee; --shadow-color:rgba(6,182,212,.3); }
.hero-card.c7 { --bg1:#10b981; --bg2:#34d399; --shadow-color:rgba(16,185,129,.3); }
.hero-card.c8 { --bg1:#6366f1; --bg2:#818cf8; --shadow-color:rgba(99,102,241,.3); }

/* ── Collapsible Sections ─────────────────────────────────────────────────── */
.section-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 22px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 2px solid var(--border-light);
}

.section-title .sec-icon { color: var(--accent-indigo); font-size: 1rem; }

.section-toggle {
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 10px 12px;
    transition: background var(--transition);
}

.section-toggle:hover { background: #f0f4ff; }

.section-chevron {
    margin-left: auto;
    font-size: .72rem;
    color: var(--text-muted);
    transition: transform .3s;
}

.section-toggle.closed .section-chevron { transform: rotate(-90deg); }

.section-body {
    overflow: hidden;
    max-height: 3000px;
    transition: max-height .4s, opacity .3s;
    opacity: 1;
    margin-bottom: 8px;
    padding-top: 14px;
}

.section-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
}

/* ── Chart Grid ───────────────────────────────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.chart-grid-3 { grid-template-columns: repeat(3, 1fr); }
.chart-grid-2 { grid-template-columns: repeat(2, 1fr); }
.chart-grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Chart Card ───────────────────────────────────────────────────────────── */
.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition), transform var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.chart-card h3 {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.chart-card h3 .card-icon { color: var(--accent-indigo); }

.chart-card .card-badge {
    margin-left: auto;
    font-size: .66rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(99,102,241,.08);
    color: var(--accent-indigo);
    border: 1px solid rgba(99,102,241,.12);
}

.chart-wrap {
    min-height: 260px;
    position: relative;
}

/* ── Loading / Error States ───────────────────────────────────────────────── */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 260px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-indigo);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.chart-loading-text {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.chart-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 260px;
    color: var(--accent-red);
}

.chart-error-icon { font-size: 28px; }
.chart-error-text { font-size: .78rem; font-weight: 500; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid var(--border-light);
}

.footer-text {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.footer-text a {
    color: var(--accent-indigo);
    text-decoration: none;
}

.footer-text a:hover { color: var(--accent-violet); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1400px) {
    .chart-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
    .chart-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .chart-grid-3 { grid-template-columns: 1fr 1fr; }
    .chart-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .header-inner { flex-direction: column; gap: 12px; text-align: center; }
    .header-meta { justify-content: center; }
    .chart-grid-5, .chart-grid-3, .chart-grid-2 { grid-template-columns: 1fr; }
    .stats-hero { grid-template-columns: 1fr 1fr; }
    .main-container { padding: 12px 12px 30px; }
}

@media (max-width: 480px) {
    .stats-hero { grid-template-columns: 1fr; }
}
