/* DDCET Prep - Atlys-Inspired Clean Modern Theme */
:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --border: #e9ecef;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --accent-light: rgba(67, 97, 238, 0.08);
    --green: #10b981;
    --red: #ef4444;
    --blue: #4361ee;
    --purple: #8b5cf6;
    --orange: #f59e0b;
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --font-mono: 'DM Mono', 'Consolas', monospace;
    --font-sans: 'DM Sans', sans-serif;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.04);
    --shadow: 0 4px 12px rgba(16,24,40,.06);
    --shadow-lg: 0 8px 24px rgba(16,24,40,.10);
    --shadow-float: 0 1px 2px rgba(16,24,40,.04), 0 16px 40px -24px rgba(16,24,40,.24);
    --ring: 0 0 0 1px rgba(16,24,40,.03);
    --ease: cubic-bezier(.2,.7,.2,1);
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Premium entrance — reveals once, then hands off to normal styles cleanly
   (backwards fill = hidden during delay, reverts after so :hover still works). */
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .card, .stat-card, .page-content > * { animation: none !important; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-nav a { position: relative; }
.sidebar-nav a:not(.active):hover { transform: translateX(2px); }

.sidebar-brand {
    padding: 24px 28px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-brand .accent { color: var(--accent); }

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
    position: relative;
}
.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    border-radius: 3px;
    background: var(--accent);
}

.sidebar-nav .nav-section {
    padding: 20px 16px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-footer img {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-footer .name { font-size: 13px; font-weight: 600; }
.sidebar-footer .plan { font-size: 11px; color: var(--accent); font-weight: 500; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

/* Navbar */
.navbar {
    height: var(--navbar-height);
    background: rgba(255,255,255,.72);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid rgba(238,240,245,.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-left { display: flex; align-items: center; gap: 16px; }
.navbar-left h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }

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

.navbar-right .xp-badge {
    background: linear-gradient(135deg, rgba(67,97,238,.12), rgba(139,92,246,.12));
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono);
    box-shadow: var(--ring);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.navbar-right .xp-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -4px rgba(67,97,238,.4);
}

.navbar-right .streak-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--orange);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(245,158,11,.10);
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: var(--ring);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

.menu-toggle:hover { background: var(--bg-tertiary); }

/* Page Content */
.page-content { padding: 32px; position: relative; }
.page-content::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(55% 45% at 15% -5%, rgba(67,97,238,.05), transparent 60%),
        radial-gradient(45% 40% at 100% 0%, rgba(139,92,246,.045), transparent 55%);
}

/* Cards */
.card {
    position: relative;
    background: linear-gradient(165deg, #ffffff 0%, #fafbff 100%);
    border: 1px solid rgba(238,240,245,.9);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--ring), var(--shadow-float);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
    animation: riseIn .5s var(--ease) backwards;
}
/* hairline top sheen for glassy depth */
.card::after {
    content: '';
    position: absolute;
    top: 0; left: 16px; right: 16px;
    height: 1px;
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(67,97,238,.14);
    box-shadow: var(--ring), 0 2px 4px rgba(16,24,40,.05), 0 26px 56px -28px rgba(16,24,40,.32);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(238,240,245,.85);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.2px;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

/* Dashboard two-column rows. Classed (not inline) so they collapse cleanly on
   narrow screens instead of relying on the [style*=...] catch-all. */
.dash-2col { display: grid; gap: 20px; margin-bottom: 24px; }
.dash-2col.wide { grid-template-columns: 2fr 1fr; }
.dash-2col.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) {
    .dash-2col.wide, .dash-2col.even { grid-template-columns: 1fr; }
}

.stat-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(165deg, #ffffff 0%, #fafbff 100%);
    border: 1px solid rgba(238,240,245,.9);
    border-radius: var(--radius-xl);
    padding: 22px 22px 20px;
    box-shadow: var(--ring), 0 1px 2px rgba(16,24,40,.04), 0 12px 30px -18px rgba(16,24,40,.18);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
    animation: riseIn .5s var(--ease) backwards;
}
.stats-grid .stat-card:nth-child(2) { animation-delay: .06s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: .12s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: .18s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: .24s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: .30s; }

/* accent bar + soft corner glow */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(var(--accent), #93a4f7);
    opacity: .95;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: -50px; right: -50px;
    width: 140px; height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(67,97,238,.10), transparent 70%);
    pointer-events: none;
    transition: transform .4s var(--ease);
}
.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(67,97,238,.18);
    box-shadow: var(--ring), 0 8px 14px -8px rgba(16,24,40,.14), 0 30px 50px -24px rgba(16,24,40,.32);
}
.stat-card:hover::after { transform: scale(1.25); }
.stat-card > * { position: relative; z-index: 1; }

.stat-card .stat-value {
    font-size: 34px;
    font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: -1px;
    line-height: 1.05;
    background: linear-gradient(180deg, var(--text-primary), #3a3a55);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-card .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 700;
}

.stat-card.accent::before { background: linear-gradient(var(--accent), #93a4f7); }
.stat-card.green::before  { background: linear-gradient(var(--green), #6ee7b7); }
.stat-card.green::after   { background: radial-gradient(circle, rgba(16,185,129,.12), transparent 70%); }
.stat-card.blue::before   { background: linear-gradient(var(--blue), #93a4f7); }
.stat-card.red::before    { background: linear-gradient(var(--red), #fca5a5); }
.stat-card.red::after     { background: radial-gradient(circle, rgba(239,68,68,.10), transparent 70%); }
.stat-card.accent .stat-value { background: linear-gradient(180deg, var(--accent), #6c7ff5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.green .stat-value  { background: linear-gradient(180deg, var(--green), #34d399);  -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.blue .stat-value   { background: linear-gradient(180deg, var(--blue), #6c7ff5);   -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.red .stat-value    { background: linear-gradient(180deg, var(--red), #f87171);    -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5a73f0);
    color: #fff;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #4a63e0); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px -6px rgba(67, 97, 238, 0.55); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e9ecef; border-color: #dee2e6; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; transform: translateY(-1px); }

.btn-success { background: var(--green); color: #fff; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3); }
.btn-success:hover { background: #059669; color: #fff; transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-light); color: var(--accent); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-dark {
    background: var(--text-primary);
    color: #fff;
}
.btn-dark:hover { background: #2d2d44; color: #fff; transform: translateY(-1px); }

.btn-orange {
    background: linear-gradient(135deg, var(--orange), #fb923c);
    color: #fff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}
.btn-orange:hover { background: linear-gradient(135deg, #d97706, #f97316); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px -6px rgba(245, 158, 11, 0.55); }

.btn-purple {
    background: var(--purple);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.btn-purple:hover { background: #7c3aed; color: #fff; transform: translateY(-1px); }

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* Tables */
.table-wrap { overflow-x: auto; }

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

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr { transition: background .15s var(--ease); }
tr:hover td { background: var(--accent-light); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green { background: rgba(16,185,129,0.1); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-blue { background: rgba(67,97,238,0.1); color: var(--blue); }

/* Progress Ring */
.progress-ring {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.progress-ring svg { transform: rotate(-90deg); }

.progress-ring .value {
    position: absolute;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 22px;
    color: var(--text-primary);
}
.progress-ring svg circle:last-child { transition: stroke-dashoffset 1.2s var(--ease); }

/* Heatmap */
.heatmap { display: flex; gap: 3px; flex-wrap: wrap; }

.heatmap-cell {
    width: 13px; height: 13px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    transition: transform .15s var(--ease);
}
.heatmap-cell:hover { transform: scale(1.35); }

.heatmap-cell.l1 { background: rgba(67,97,238,0.2); }
.heatmap-cell.l2 { background: rgba(67,97,238,0.4); }
.heatmap-cell.l3 { background: rgba(67,97,238,0.65); }
.heatmap-cell.l4 { background: var(--accent); box-shadow: 0 0 8px rgba(67,97,238,.5); }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.form-control:hover { border-color: #d3d9e0; }
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--ring);
}

/* Locked overlay */
.locked-overlay {
    position: relative;
    filter: blur(3px);
    pointer-events: none;
}

.lock-prompt {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248,249,250,0.85);
    z-index: 10;
    border-radius: var(--radius-lg);
}

/* Icons */
.icon { flex-shrink: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 3px; }

.mathy {
    overflow-x: auto;
    max-width: 100%;
}

/* Responsive */
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar.collapsed ~ .main-content { margin-left: 0; width: 100%; }

/* Mobile sidebar backdrop (hidden on desktop) */
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); position: fixed; z-index: 200; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150; display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
    .stat-card { padding: 16px; border-radius: 14px; }
    .stat-card .stat-value { font-size: 24px; }
    .page-content { padding: 16px 12px; min-height: calc(100vh - 64px); }
    .navbar { padding: 0 12px; }
    .navbar h2 { font-size: 16px; }
    .card { padding: 14px; border-radius: 10px; overflow: hidden; word-wrap: break-word; }
    .card-header h3 { font-size: 14px; }
    /* Tables stay as real tables and scroll sideways on small screens. The old
       approach hid <thead> and relabelled each cell via data-label, but no cell
       in the app sets data-label, so it produced unlabelled value columns. Wide
       admin tables (6-9 cols) keep their header and scroll horizontally instead,
       which is robust for every table without touching any PHP. */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* width:auto + min-width:100% + nowrap = narrow tables (2-3 cols) fit the
       screen with no scroll, while wide admin tables keep their natural width
       and scroll sideways instead of crushing. Standard responsive-table behaviour. */
    .table-wrap table { width: auto; min-width: 100%; }
    .table-wrap th, .table-wrap td { white-space: nowrap; font-size: 13px; padding: 8px 10px; }
    .form-control { font-size: 16px; }
    .btn { padding: 8px 14px; font-size: 12px; }
    .btn-sm { padding: 6px 12px; font-size: 11px; }
    .heatmap { overflow-x: auto; }
    /* Specific utility classes to override flex/grid on mobile where intended */
    .mobile-wrap { flex-wrap: wrap !important; }
    .mobile-stack { flex-direction: column !important; align-items: stretch !important; }
    .grid-1-mobile { grid-template-columns: 1fr !important; }
    /* Prevent overflow */
    p, h1, h2, h3, h4, span, div { overflow-wrap: break-word; word-break: break-word; }
    .tag, .badge { font-size: 10px; padding: 3px 8px; }
    .sidebar-footer { padding: 12px 16px; }
    .menu-toggle { display: flex !important; }
}

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