/* ============================================================
   EduMate — Design System & Global Styles
   AI WAEC Learning & Exam Preparation Platform
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Primary palette */
    --primary-50: #EEF2FF;
    --primary-100: #E0E7FF;
    --primary-200: #C7D2FE;
    --primary-300: #A5B4FC;
    --primary-400: #818CF8;
    --primary-500: #6366F1;
    --primary-600: #4F46E5;
    --primary-700: #4338CA;
    --primary-800: #3730A3;
    --primary-900: #312E81;

    /* Accent / Success */
    --accent-400: #34D399;
    --accent-500: #10B981;
    --accent-600: #059669;

    /* Warning */
    --warning-400: #FBBF24;
    --warning-500: #F59E0B;

    /* Danger */
    --danger-400: #F87171;
    --danger-500: #EF4444;
    --danger-600: #DC2626;

    /* Neutrals */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Surface (dark mode) */
    --surface-bg: #0F1117;
    --surface-card: #1A1D2E;
    --surface-card-hover: #232640;
    --surface-border: #2A2D3E;
    --surface-input: #1E2235;

    /* Text */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-inverse: #0F172A;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366F1, #8B5CF6);
    --gradient-accent: linear-gradient(135deg, #10B981, #06B6D4);
    --gradient-warm: linear-gradient(135deg, #F59E0B, #EF4444);
    --gradient-cool: linear-gradient(135deg, #3B82F6, #8B5CF6);
    --gradient-card: linear-gradient(145deg, #1A1D2E, #232640);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-400);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-300);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 1.875rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent-500);
}

.text-danger {
    color: var(--danger-500);
}

.text-warning {
    color: var(--warning-500);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-center {
    text-align: center;
}

.font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Layout: App Shell --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

.app-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-card);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-weight: 700;
    font-size: 1.125rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.sidebar-section {
    padding: 8px 16px 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary-400);
    border-left-color: var(--primary-500);
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-link .badge {
    margin-left: auto;
    background: var(--primary-600);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--surface-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--gradient-cool);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--surface-input);
}

/* --- Cards --- */
.card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    font-size: 1rem;
    font-weight: 600;
}

/* Stat Cards */
.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    color: #fff;
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--surface-input);
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background: var(--surface-card-hover);
    color: var(--text-primary);
}

.btn-accent {
    background: var(--gradient-accent);
    color: #fff;
}

.btn-accent:hover {
    filter: brightness(1.1);
    color: #fff;
}

.btn-danger {
    background: var(--danger-600);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-500);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface-input);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239CA3AF' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: var(--surface-input);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-top: 1px solid var(--surface-border);
    color: var(--text-primary);
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-400);
}

.badge-accent {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-400);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-400);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-400);
}

.badge-gray {
    background: var(--surface-input);
    color: var(--text-secondary);
}

/* --- Progress Bar --- */
.progress {
    width: 100%;
    height: 8px;
    background: var(--surface-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    transition: width var(--transition-slow);
}

.progress-bar.accent {
    background: var(--gradient-accent);
}

.progress-bar.warning {
    background: var(--warning-500);
}

.progress-bar.danger {
    background: var(--danger-500);
}

/* --- Alerts / Flash Messages --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-400);
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger-400);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-400);
}

.alert-info {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary-400);
}

/* --- Grid Utilities --- */
.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);
}

.grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: 8px;
}

.gap-md {
    gap: 16px;
}

.gap-lg {
    gap: 24px;
}

.mb-sm {
    margin-bottom: 8px;
}

.mb-md {
    margin-bottom: 16px;
}

.mb-lg {
    margin-bottom: 24px;
}

.mt-md {
    margin-top: 16px;
}

.mt-lg {
    margin-top: 24px;
}

/* --- Readiness Gauge --- */
.readiness-gauge {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.readiness-gauge svg {
    transform: rotate(-90deg);
}

.readiness-gauge .gauge-bg {
    fill: none;
    stroke: var(--surface-input);
    stroke-width: 12;
}

.readiness-gauge .gauge-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.readiness-gauge .gauge-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.readiness-gauge .gauge-value {
    font-size: 2rem;
    font-weight: 700;
}

.readiness-gauge .gauge-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Chat UI (AI Tutor) --- */
.chat-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 0;
    height: calc(100vh - var(--topbar-height) - 48px);
    background: var(--surface-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    overflow: hidden;
}

.chat-sidebar {
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    background: var(--surface-bg);
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--surface-border);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: auto;
    text-overflow: ellipsis;
}

.chat-history-item:hover,
.chat-history-item.active {
    background: var(--surface-card);
    color: var(--text-primary);
}

.chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    animation: fadeInUp 0.3s ease;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--primary-600);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--surface-input);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-message.assistant pre {
    background: var(--surface-bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85rem;
}

.chat-message.assistant code {
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--surface-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface-input);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--primary-500);
}

.chat-send {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-send:hover {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

/* --- Exam UI --- */
.exam-timer {
    position: sticky;
    top: var(--topbar-height);
    z-index: 30;
    background: var(--surface-card);
    border-bottom: 1px solid var(--surface-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exam-timer .timer-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-400);
}

.exam-timer .timer-display.warning {
    color: var(--warning-400);
}

.exam-timer .timer-display.danger {
    color: var(--danger-400);
}

.question-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 16px;
}

.question-number {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.question-text {
    font-size: 1rem;
    margin-bottom: 16px;
    line-height: 1.6;
}

.option-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-input);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.option-item:hover {
    border-color: var(--primary-500);
    background: rgba(99, 102, 241, 0.08);
}

.option-item.selected {
    border-color: var(--primary-500);
    background: rgba(99, 102, 241, 0.12);
}

.option-item.correct {
    border-color: var(--accent-500);
    background: rgba(16, 185, 129, 0.12);
}

.option-item.incorrect {
    border-color: var(--danger-500);
    background: rgba(239, 68, 68, 0.12);
}

.option-item input[type="radio"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--surface-border);
    border-radius: 50%;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.option-item input[type="radio"]:checked {
    border-color: var(--primary-500);
    background: var(--primary-500);
    box-shadow: inset 0 0 0 3px var(--surface-card);
}

/* --- Subject Cards --- */
.subject-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-normal);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.subject-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(99, 102, 241, 0.3);
    color: inherit;
}

.subject-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.subject-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.subject-card-title {
    font-weight: 600;
    font-size: 1rem;
}

.subject-card-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Auth Pages --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-bg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    bottom: -100px;
    left: -100px;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}

.auth-logo h1 {
    font-size: 1.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Auth divider ("or") */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--surface-border);
}

.auth-divider span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Google Sign-In button */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.btn-google:hover {
    background: #f8f9fa;
    border-color: #c6c6c6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #3c4043;
}

.btn-google:active {
    background: #e8eaed;
}

.btn-google svg {
    flex-shrink: 0;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    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;
    }
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }
}

/* --- Chat Action Buttons (File/Camera) --- */
.chat-action-btn {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.chat-action-btn:hover:not(.locked) {
    color: var(--primary-400);
    border-color: var(--primary-400);
    background: rgba(99, 102, 241, 0.08);
}

.chat-action-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.chat-file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.06);
    border-top: 1px solid var(--surface-border);
    font-size: 0.85rem;
}

.chat-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-file-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-file-remove:hover {
    color: var(--danger-400);
}

/* --- Plan / Pricing Cards --- */
.plan-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all var(--transition-normal);
}

.plan-card:hover {
    border-color: var(--primary-500);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
}

.plan-featured {
    border-color: var(--primary-500);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.12);
}

.plan-active {
    border-color: var(--accent-500) !important;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.15) !important;
}

.plan-popular {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 4px 16px;
    border-radius: 20px;
}

.plan-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.plan-price {
    margin-bottom: 8px;
    line-height: 1;
}

.plan-currency {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-400);
    vertical-align: top;
    position: relative;
    top: 6px;
}

.plan-amount {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
}

.plan-decimal {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-interval {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.plan-savings {
    font-size: 0.8rem;
    color: var(--warning-400);
    margin-bottom: 8px;
}

.plan-trial {
    font-size: 0.8rem;
    color: var(--accent-400);
    background: rgba(16, 185, 129, 0.08);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    flex: 1;
}

.plan-features li {
    padding: 7px 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.plan-features li i {
    color: var(--accent-400);
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.plan-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Responsive --- */

/* Large screens — constrain wide layouts */
@media (max-width: 1200px) {
    .app-content {
        max-width: 100%;
    }
}

/* Tablets and small laptops */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .chat-container {
        grid-template-columns: 200px 1fr;
    }

    .app-content {
        padding: 20px;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .readiness-gauge {
        width: 140px;
        height: 140px;
    }

    .readiness-gauge .gauge-value {
        font-size: 1.5rem;
    }
}

/* Mobile breakpoint — sidebar offcanvas */
@media (max-width: 768px) {

    /* Sidebar goes off-screen */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        width: var(--sidebar-width);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .app-main {
        margin-left: 0;
    }

    /* Show hamburger */
    .menu-toggle {
        display: flex;
    }

    /* Grids: single column */
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-auto {
        grid-template-columns: 1fr;
    }

    /* Reduce padding */
    .topbar {
        padding: 0 12px;
    }

    .topbar-title {
        font-size: 1rem;
    }

    .app-content {
        padding: 12px;
    }

    /* Cards */
    .card {
        padding: 16px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Stat cards: horizontal but compact */
    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.125rem;
    }

    /* Chat UI */
    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100vh - var(--topbar-height) - 24px);
    }

    .chat-sidebar {
        display: none;
    }

    .chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .chat-message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .chat-input-area {
        padding: 12px;
        gap: 8px;
    }

    .chat-input {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .chat-send {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Auth pages */
    .auth-card {
        padding: 24px;
        margin: 0 8px;
    }

    .auth-logo h1 {
        font-size: 1.25rem;
    }

    /* Tables */
    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    /* Subject cards */
    .subject-card {
        padding: 16px;
    }

    .subject-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Exam UI */
    .exam-timer {
        padding: 10px 12px;
        gap: 8px;
    }

    .exam-timer .timer-display {
        font-size: 1rem;
    }

    .question-card {
        padding: 16px;
    }

    .option-item {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Typography */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Readiness gauge */
    .readiness-gauge {
        width: 130px;
        height: 130px;
    }

    .readiness-gauge .gauge-value {
        font-size: 1.4rem;
    }

    /* Buttons */
    .btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .btn-lg {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    /* Hide text in topbar logout on very small */
    .topbar-right .btn span.hide-mobile {
        display: none;
    }

    /* Badge */
    .badge {
        padding: 2px 8px;
        font-size: 0.65rem;
    }

    /* Empty state */
    .empty-state {
        padding: 32px 16px;
    }

    .empty-state .icon {
        font-size: 2.5rem;
    }

    /* Force inline grid styles to single column on mobile */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .exam-timer {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }

    .topbar-title {
        font-size: 0.9rem;
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-content {
        padding: 8px;
    }

    .card {
        padding: 12px;
        border-radius: var(--radius-sm);
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    /* Chat */
    .chat-container {
        height: calc(100vh - var(--topbar-height) - 16px);
        border-radius: var(--radius-sm);
    }

    .chat-messages {
        padding: 10px;
    }

    .chat-message {
        max-width: 95%;
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .chat-input-area {
        padding: 8px;
    }

    /* Option items */
    .option-item {
        padding: 8px 10px;
        gap: 8px;
        font-size: 0.82rem;
    }

    .option-item input[type="radio"] {
        width: 16px;
        height: 16px;
    }

    /* Auth */
    .auth-card {
        padding: 20px 16px;
    }

    .auth-logo .logo-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .auth-logo {
        margin-bottom: 20px;
    }

    /* Question cards */
    .question-card {
        padding: 12px;
    }

    .question-text {
        font-size: 0.9rem;
    }

    /* Sidebar when open */
    .sidebar {
        width: 80vw;
        max-width: 280px;
    }

    /* Table cells */
    .table th,
    .table td {
        padding: 8px;
        font-size: 0.75rem;
    }
}

/* Wide screens — max width and center */
@media (min-width: 1600px) {
    .app-content {
        max-width: 1400px;
    }

    .grid-4 {
        gap: 24px;
    }

    .grid-3 {
        gap: 24px;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-700);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* --- Backdrop overlay for mobile sidebar --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}