/* ============================================================
   NeetPrep AI — Premium Dark Theme
   ============================================================ */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-cyan: #06b6d4;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-danger: linear-gradient(135deg, #f43f5e, #ec4899);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #f97316);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --sidebar-width: 240px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
    background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(20px);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    z-index: 100; transition: var(--transition);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px; padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 28px; }
.brand-text { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.brand-ai { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    text-decoration: none; transition: var(--transition); font-weight: 500; font-size: 14px;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-name { font-size: 13px; color: var(--text-secondary); }
.btn-logout {
    width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12px; transition: var(--transition);
}
.btn-logout:hover { border-color: var(--accent-rose); color: var(--accent-rose); }

/* ---- Main Content ---- */
.main-content { padding: 32px; min-height: 100vh; }
.main-content.with-sidebar { margin-left: var(--sidebar-width); }

/* ---- Cards ---- */
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; transition: var(--transition); backdrop-filter: blur(10px);
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-glow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 18px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---- Grid ---- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .main-content.with-sidebar { margin-left: 0; } .sidebar { display: none; } }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; display: flex; align-items: center; gap: 16px; transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.stat-icon { font-size: 32px; width: 56px; height: 56px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
    border: none; cursor: pointer; transition: var(--transition); text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--gradient-primary); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4); }
.btn-success { background: var(--gradient-success); color: #fff; }
.btn-danger { background: var(--gradient-danger); color: #fff; }
.btn-warning { background: var(--gradient-warning); color: #fff; }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ---- Form Controls ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-select, .form-input {
    width: 100%; padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; font-family: inherit;
    transition: var(--transition); outline: none;
}
.form-select:focus, .form-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.form-select option { background: var(--bg-secondary); }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-high { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-low { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

/* ---- Progress Bar ---- */
.progress-bar { width: 100%; height: 6px; background: var(--bg-secondary); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 32px; }
.page-title { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { font-size: 15px; color: var(--text-muted); }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
    font-size: 14px; font-weight: 500; animation: slideDown 0.3s ease;
}
.alert-error { background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.3); color: #fb7185; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }

/* ---- Toasts ---- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    transform: translateX(120%); transition: var(--transition); min-width: 280px;
    backdrop-filter: blur(20px);
}
.toast.show { transform: translateX(0); }
.toast-success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.toast-error { background: rgba(244, 63, 94, 0.15); border: 1px solid rgba(244, 63, 94, 0.3); color: #fb7185; }
.toast-info { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.3); color: #60a5fa; }

/* ---- Quiz Specific ---- */
.quiz-container { max-width: 800px; margin: 0 auto; }
.question-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 32px; margin-bottom: 24px;
}
.question-number { font-size: 12px; font-weight: 700; color: var(--accent-blue); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.question-text { font-size: 17px; font-weight: 500; line-height: 1.7; margin-bottom: 24px; }
.options-grid { display: flex; flex-direction: column; gap: 12px; }
.option-btn {
    display: flex; align-items: center; gap: 14px; padding: 16px 20px;
    background: var(--bg-secondary); border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: var(--transition); font-size: 15px; text-align: left; color: var(--text-primary);
    font-family: inherit;
}
.option-btn:hover { border-color: var(--accent-blue); background: rgba(59, 130, 246, 0.05); }
.option-btn.selected { border-color: var(--accent-blue); background: rgba(59, 130, 246, 0.1); }
.option-btn.correct { border-color: var(--accent-emerald); background: rgba(16, 185, 129, 0.1); }
.option-btn.wrong { border-color: var(--accent-rose); background: rgba(244, 63, 94, 0.1); }
.option-letter {
    width: 32px; height: 32px; border-radius: 50%; background: var(--bg-card);
    border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0; transition: var(--transition);
}
.option-btn.selected .option-letter { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.option-btn.correct .option-letter { background: var(--accent-emerald); border-color: var(--accent-emerald); color: #fff; }
.option-btn.wrong .option-letter { background: var(--accent-rose); border-color: var(--accent-rose); color: #fff; }
.explanation-box {
    margin-top: 16px; padding: 16px; background: rgba(59, 130, 246, 0.05);
    border-left: 3px solid var(--accent-blue); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px; line-height: 1.6; color: var(--text-secondary); display: none;
}
.explanation-box.show { display: block; animation: fadeIn 0.3s ease; }

/* ---- Quiz Timer ---- */
.quiz-timer {
    position: sticky; top: 0; z-index: 50; padding: 12px 24px;
    background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.timer-display { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; }

/* ---- Quiz Palette ---- */
.quiz-palette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.palette-btn {
    width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-secondary); color: var(--text-muted); font-size: 12px; font-weight: 600;
    cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center;
}
.palette-btn.current { border-color: var(--accent-blue); color: var(--accent-blue); }
.palette-btn.answered { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.palette-btn.correct-p { background: var(--accent-emerald); color: #fff; border-color: var(--accent-emerald); }
.palette-btn.wrong-p { background: var(--accent-rose); color: #fff; border-color: var(--accent-rose); }

/* ---- Chat ---- */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 120px); max-width: 900px; margin: 0 auto; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px 0; display: flex; flex-direction: column; gap: 16px; }
.chat-msg {
    max-width: 85%; padding: 14px 18px; border-radius: var(--radius-lg); font-size: 14px; line-height: 1.7;
    animation: fadeIn 0.3s ease;
}
.chat-msg.user { align-self: flex-end; background: var(--gradient-primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg .model-badge { font-size: 10px; opacity: 0.6; margin-bottom: 4px; display: block; }
.chat-input-area {
    display: flex; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border);
}
.chat-input-area .form-input { flex: 1; }

/* ---- Study Cards ---- */
.chapter-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; transition: var(--transition); cursor: pointer; position: relative; overflow: hidden;
}
.chapter-card:hover { transform: translateY(-2px); border-color: var(--border-hover); box-shadow: var(--shadow-glow); }
.chapter-card .priority-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.chapter-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.chapter-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; align-items: center; }

/* ---- Mastery Indicator ---- */
.mastery-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}

/* ---- Results ---- */
.score-ring {
    width: 160px; height: 160px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: conic-gradient(var(--accent-blue) var(--score-pct, 0%), var(--bg-secondary) 0%);
    margin: 0 auto 24px; position: relative;
}
.score-ring-inner {
    width: 130px; height: 130px; border-radius: 50%; background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.score-value { font-size: 32px; font-weight: 800; }
.score-max { font-size: 13px; color: var(--text-muted); }

/* ---- Subject Tabs ---- */
.subject-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.subject-tab {
    padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600;
    background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
    cursor: pointer; transition: var(--transition); text-decoration: none;
}
.subject-tab:hover, .subject-tab.active { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(59, 130, 246, 0.05); }

/* ---- Loading ---- */
.loading-spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--accent-blue); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
    width: 100%; max-width: 420px; padding: 40px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    backdrop-filter: blur(20px); text-align: center;
}
.login-card h1 { font-size: 36px; font-weight: 900; margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 32px; }
.login-card .form-input { text-align: center; font-size: 18px; padding: 14px; margin-bottom: 16px; }
.login-card .btn { width: 100%; padding: 14px; font-size: 16px; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 16px; color: var(--text-muted); margin-bottom: 20px; }

/* ---- Flex Utilities ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-blue { color: var(--accent-blue); }
.text-emerald { color: var(--accent-emerald); }
.text-rose { color: var(--accent-rose); }
.text-amber { color: var(--accent-amber); }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
