/* ===== RESET & ROOT ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 240px;
    --topbar-h: 68px;

    /* Brand palette — deep indigo + saffron accent */
    --brand-900: #1a1063;
    --brand-800: #231580;
    --brand-700: #2f1fa8;
    --brand-600: #3d28cc;
    --brand-500: #4e35e8;
    --brand-400: #7261f0;
    --brand-300: #a090f5;
    --brand-200: #cec8fb;
    --brand-100: #eceafe;
    --brand-50:  #f5f4ff;

    --accent:       #f5a623;
    --accent-light: #fef3dc;
    --accent-dark:  #c27d00;

    /* Grays */
    --gray-950: #0d0d0f;
    --gray-900: #16161a;
    --gray-800: #1e1e24;
    --gray-700: #2a2a34;
    --gray-600: #3f3f50;
    --gray-500: #6b6b80;
    --gray-400: #9898ae;
    --gray-300: #c4c4d4;
    --gray-200: #e2e2ec;
    --gray-100: #f1f1f7;
    --gray-50:  #f8f8fc;

    /* Semantic */
    --success:       #12b76a;
    --success-light: #d1fadf;
    --warning:       #f79009;
    --warning-light: #fef0c7;
    --danger:        #f04438;
    --danger-light:  #fee4e2;

    /* Category colors */
    --purple-bg: #ede9fe; --purple-fg: #5b21b6;
    --teal-bg:   #ccfbf1; --teal-fg:   #0f766e;
    --amber-bg:  #fef3c7; --amber-fg:  #92400e;
    --coral-bg:  #ffe4e6; --coral-fg:  #9f1239;
    --blue-bg:   #dbeafe; --blue-fg:   #1e40af;
    --green-bg:  #dcfce7; --green-fg:  #166534;

    /* Typography */
    --font-main: 'Sora', sans-serif;
    --font-bn:   'Hind Siliguri', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);

    /* Radius */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-xl: 22px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 15px; }

body {
    font-family: var(--font-main);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}


/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--brand-900);
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 200;
    overflow-y: auto;
    transition: transform 0.3s var(--ease);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 18px;
    color: var(--brand-900);
    flex-shrink: 0;
}

.brand-text { display: flex; gap: 3px; align-items: baseline; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.02em; }
.brand-suffix { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-exam { font-size: 11px; color: var(--brand-300); }

.user-streak { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.streak-icon { font-size: 14px; line-height: 1; }
.streak-num  { font-size: 10px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 20px;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--brand-300);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s var(--ease);
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.2);
}

.nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    width: 17px; height: 17px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon { opacity: 1; }

.nav-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 8px 20px; }

.nav-logout { color: rgba(240, 68, 56, 0.7); margin-top: auto; }
.nav-logout:hover { color: #f04438; border-left-color: #f04438; background: rgba(240, 68, 56, 0.08); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}


/* ===== MAIN ===== */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}


/* ===== TOPBAR ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: rgba(248,248,252,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}
.hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all 0.2s;
}

.greeting-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.greeting-sub { font-size: 12px; color: var(--gray-500); }

.days-left {
    color: var(--accent-dark);
    font-weight: 600;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 24px;
    padding: 7px 14px;
    transition: all 0.2s;
}
.search-box:focus-within {
    background: #fff;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.search-box svg { width: 15px; height: 15px; color: var(--gray-400); flex-shrink: 0; }
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--gray-900);
    width: 180px;
}
.search-box input::placeholder { color: var(--gray-400); }

.notif-btn {
    position: relative;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-600);
}
.notif-btn svg { width: 17px; height: 17px; }
.notif-btn:hover { background: #fff; border-color: var(--brand-400); color: var(--brand-600); }

.notif-dot {
    position: absolute;
    top: 7px; right: 8px;
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--gray-50);
}


/* ===== DASHBOARD BODY ===== */
.dashboard-body {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
}


/* ===== STAT CARDS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.4s var(--ease) both;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    border-radius: 3px 0 0 3px;
}
.stat-rank::before  { background: var(--accent); }
.stat-avg::before   { background: var(--brand-500); }
.stat-tests::before { background: var(--success); }
.stat-streak::before { background: #f97316; }

.stat-icon {
    width: 42px; height: 42px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-rank .stat-icon  { background: var(--accent-light); color: var(--accent-dark); }
.stat-avg .stat-icon   { background: var(--brand-100); color: var(--brand-600); }
.stat-tests .stat-icon { background: var(--success-light); color: var(--success); }
.stat-streak .stat-icon { background: #fff3eb; font-size: 22px; }

.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); letter-spacing: -0.03em; font-family: var(--font-mono); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 1px; }

.stat-trend {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 20px;
    flex-shrink: 0;
    font-family: var(--font-mono);
}
.stat-trend.up { background: var(--success-light); color: var(--success); }
.stat-trend.neutral { background: var(--brand-100); color: var(--brand-600); }


/* ===== PANEL ===== */
.panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--gray-100);
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.panel-link {
    font-size: 12.5px;
    color: var(--brand-500);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.panel-link:hover { color: var(--brand-700); }


/* ===== CONTENT GRID ===== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.right-col { display: flex; flex-direction: column; gap: 24px; }


/* ===== CATEGORY CARDS ===== */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--r-lg);
    border: 1.5px solid transparent;
    text-decoration: none;
    transition: all 0.2s var(--ease);
    animation: fadeUp 0.4s var(--ease) both;
    position: relative;
    overflow: hidden;
}

.cat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(255,255,255,0.5);
}
.cat-card:hover::after { opacity: 1; }
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.cat-purple { background: var(--purple-bg); border-color: rgba(91,33,182,0.15); }
.cat-teal   { background: var(--teal-bg);   border-color: rgba(15,118,110,0.15); }
.cat-amber  { background: var(--amber-bg);  border-color: rgba(146,64,14,0.15); }
.cat-coral  { background: var(--coral-bg);  border-color: rgba(159,18,57,0.15); }
.cat-blue   { background: var(--blue-bg);   border-color: rgba(30,64,175,0.15); }
.cat-green  { background: var(--green-bg);  border-color: rgba(22,101,52,0.15); }

.cat-icon-wrap {
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    position: relative; z-index: 1;
}

.cat-info { flex: 1; min-width: 0; position: relative; z-index: 1; }
.cat-name { font-size: 13.5px; font-weight: 600; color: var(--gray-900); }
.cat-bn   { font-family: var(--font-bn); font-size: 12px; color: var(--gray-600); line-height: 1.2; }
.cat-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

.cat-arrow {
    font-size: 16px;
    color: var(--gray-400);
    position: relative; z-index: 1;
    transition: transform 0.2s;
}
.cat-card:hover .cat-arrow { transform: translateX(3px); color: var(--gray-600); }


/* ===== COUNTDOWN ===== */
.countdown-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 22px;
}

.ring-wrap {
    position: relative;
    width: 90px; height: 90px;
    flex-shrink: 0;
}

.ring-svg { width: 90px; height: 90px; transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: var(--gray-100); stroke-width: 8; }
.ring-fill {
    fill: none;
    stroke: var(--brand-500);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s var(--ease);
}

.ring-center {
    position: absolute;
    inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
}
.ring-days { font-size: 20px; font-weight: 700; color: var(--gray-900); font-family: var(--font-mono); line-height: 1; }
.ring-lbl  { font-size: 9px; color: var(--gray-500); margin-top: 2px; }

.countdown-info { display: flex; flex-direction: column; gap: 8px; }
.ci-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray-600); }
.ci-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ci-done { background: var(--brand-500); }
.ci-left { background: var(--gray-200); }
.ci-exam { background: var(--accent); }


/* ===== LEADERBOARD ===== */
.lb-list { padding: 8px 0; }

.lb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 22px;
    transition: background 0.15s;
}
.lb-row:hover { background: var(--gray-50); }

.lb-top { background: linear-gradient(90deg, rgba(78,53,232,0.04) 0%, transparent 100%); }

.lb-rank {
    width: 28px;
    font-size: 15px;
    text-align: center;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-500);
}

.lb-name { flex: 1; font-size: 13px; color: var(--gray-800); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.lb-score { font-size: 12px; font-family: var(--font-mono); font-weight: 700; color: var(--brand-600); }

.lb-you { background: var(--brand-50); border-top: 1px dashed var(--brand-200); margin-top: 4px; }
.lb-you .lb-name { color: var(--brand-700); }
.lb-you .lb-rank { color: var(--brand-600); }

.you-tag {
    font-size: 10px;
    padding: 1px 6px;
    background: var(--brand-100);
    color: var(--brand-700);
    border-radius: 20px;
    font-weight: 600;
}


/* ===== RECENT TESTS TABLE ===== */
.recent-panel { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.results-table th {
    text-align: left;
    padding: 11px 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.result-row { transition: background 0.15s; }
.result-row:hover { background: var(--gray-50); }
.result-row td { padding: 13px 20px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.result-row:last-child td { border-bottom: none; }

.td-subject { min-width: 140px; }
.rs-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.rs-bn   { font-family: var(--font-bn); font-size: 12px; color: var(--gray-500); }

.score-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.score-good { background: var(--success-light); color: #057a55; }
.score-mid  { background: var(--warning-light); color: #92400e; }
.score-low  { background: var(--danger-light);  color: #b42318; }

.td-bar { min-width: 150px; }
.bar-wrap { height: 6px; background: var(--gray-100); border-radius: 3px; margin-bottom: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 1s var(--ease); }
.bar-good { background: var(--success); }
.bar-mid  { background: var(--warning); }
.bar-low  { background: var(--danger); }
.bar-pct  { font-size: 11px; font-family: var(--font-mono); color: var(--gray-500); font-weight: 600; }

.diff-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}
.diff-easy   { background: #dcfce7; color: #166534; }
.diff-medium { background: var(--warning-light); color: #92400e; }
.diff-hard   { background: var(--danger-light);  color: #b42318; }

.td-time { font-size: 12px; color: var(--gray-500); white-space: nowrap; }

.review-btn {
    display: inline-block;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-600);
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: var(--r-sm);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.review-btn:hover { background: var(--brand-100); border-color: var(--brand-400); color: var(--brand-800); }


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

.stats-row .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-row .stat-card:nth-child(2) { animation-delay: 0.10s; }
.stats-row .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-row .stat-card:nth-child(4) { animation-delay: 0.20s; }

.panel { animation: fadeUp 0.4s var(--ease) 0.15s both; }
.recent-panel { animation-delay: 0.25s; }


/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    :root { --sidebar-w: 220px; }
    .content-grid { grid-template-columns: 1fr 270px; }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 240px; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-overlay.open { display: block; }

    .main { margin-left: 0; }

    .hamburger { display: flex; }

    .content-grid {
        grid-template-columns: 1fr;
    }
    .right-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

    .stats-row { grid-template-columns: repeat(2, 1fr); }

    .search-box input { width: 130px; }
}

@media (max-width: 600px) {
    .dashboard-body { padding: 16px; gap: 16px; }
    .topbar { padding: 0 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 18px; }
    .cat-grid { grid-template-columns: 1fr; }
    .right-col { grid-template-columns: 1fr; }
    .greeting-title { font-size: 14px; }
    .search-box { display: none; }
}

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