/* ========================================
   LearnSTEM - Production CSS
   Modern, Responsive, Accessible Design
   ======================================== */

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

/* ==================== CSS VARIABLES ==================== */
:root {
    /* Colors - 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;
    
    /* Colors - Secondary Palette */
    --secondary-500: #8b5cf6;
    --secondary-600: #7c3aed;
    --secondary-700: #6d28d9;
    
    /* Colors - Semantic */
    --success-50: #d1fae5;
    --success-500: #10b981;
    --success-600: #059669;
    --danger-50: #fee2e2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --warning-50: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --info-500: #3b82f6;
    
    /* Neutral Colors */
    --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;
    
    /* Application Colors */
    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-500);
    --border-color: var(--gray-200);
    --border-hover: var(--gray-300);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 9999px;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
    
    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    
    /* Font Weights */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;
    
    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 2;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: var(--gray-900);
        --bg-secondary: var(--gray-800);
        --bg-tertiary: var(--gray-700);
        --text-primary: var(--gray-50);
        --text-secondary: var(--gray-300);
        --text-tertiary: var(--gray-400);
        --border-color: var(--gray-700);
        --border-hover: var(--gray-600);
    }
}

/* ==================== GLOBAL STYLES ==================== */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    color: white;
}

.loader-logo {
    font-size: var(--text-4xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-6);
    animation: pulse 2s ease-in-out infinite;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-4);
}

.loader-content p {
    font-size: var(--text-sm);
    opacity: 0.9;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ==================== AUTHENTICATION SECTION ==================== */
.auth-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-4);
}

.auth-container {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-10);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-2xl);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--space-8);
}

.logo-icon {
    display: inline-block;
    margin-bottom: var(--space-4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.auth-logo h1 {
    font-size: var(--text-4xl);
    font-weight: var(--font-extrabold);
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: var(--text-base);
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-1);
}

.auth-tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    transition: all var(--transition-base);
    position: relative;
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    background: var(--bg-primary);
    color: var(--primary-600);
    box-shadow: var(--shadow-sm);
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-group input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: all var(--transition-base);
    background: var(--bg-primary);
}

.form-group input:hover {
    border-color: var(--border-hover);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

/* Password Input Wrapper */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: var(--space-12);
}

.toggle-password {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition-base);
}

.toggle-password:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Field Errors */
.field-error {
    display: block;
    color: var(--danger-500);
    font-size: var(--text-sm);
    margin-top: var(--space-2);
}

/* Password Strength */
.password-strength {
    margin-top: var(--space-2);
}

.strength-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.strength-fill {
    height: 100%;
    background: var(--gray-300);
    transition: all var(--transition-base);
    width: 0%;
}

.strength-fill.weak {
    width: 33%;
    background: var(--danger-500);
}

.strength-fill.medium {
    width: 66%;
    background: var(--warning-500);
}

.strength-fill.strong {
    width: 100%;
    background: var(--success-500);
}

.strength-text {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    font-size: var(--text-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    accent-color: var(--primary-500);
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary-600);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    transition: color var(--transition-base);
}

.link-btn:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: var(--space-3) var(--space-6);
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-primary);
    color: var(--primary-600);
    border: 2px solid var(--primary-500);
    border-radius: var(--radius-md);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-secondary:hover {
    background: var(--primary-500);
    color: white;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.auth-error {
    color: var(--danger-500);
    font-size: var(--text-sm);
    margin-top: var(--space-4);
    text-align: center;
    padding: var(--space-3);
    background: var(--danger-50);
    border-radius: var(--radius);
    display: none;
}

.auth-error:not(:empty) {
    display: block;
}

/* ==================== MAIN APP SECTION ==================== */
.app-section {
    min-height: 100vh;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

/* ==================== HEADER ==================== */
.app-header {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50; /* Above modal (30) and nav (40) */
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--primary-600);
    text-decoration: none;
}

.logo svg {
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

/* User Stats */
.user-stats {
    display: flex;
    gap: var(--space-6);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: var(--danger-500);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

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

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.user-name {
    font-weight: var(--font-medium);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    z-index: var(--z-dropdown);
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-2) 0;
}

/* ==================== NAVIGATION TABS ==================== */
.nav-tabs {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 73px;
    z-index: 40; /* Above modal (30), below header (50) */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tabs {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    gap: var(--space-2);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all var(--transition-base);
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 44px;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
    background: var(--bg-secondary);
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ==================== ADVERTISEMENT SPACES ==================== */
.ad-space {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-tertiary);
    margin: var(--space-6) auto;
    max-width: 1400px;
    transition: all var(--transition-base);
}

.ad-space:hover {
    border-color: var(--border-hover);
}

.ad-top, .ad-bottom {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.ad-modal {
    min-height: 250px;
    margin-top: var(--space-6);
    padding: var(--space-6);
}

.ad-placeholder {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.ad-placeholder p {
    font-weight: var(--font-medium);
    font-size: var(--text-base);
}

.ad-placeholder small {
    font-size: var(--text-xs);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
    flex: 1;
    width: 100%;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* Section Header */
.section-header {
    margin-bottom: var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.section-header h2 {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
    margin-top: var(--space-2);
}

.section-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

/* Search Box */
.search-box {
    position: relative;
    width: 300px;
}

.search-box svg {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: all var(--transition-base);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Chapter Selector */
.chapter-selector {
    background: var(--bg-primary);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.chapter-selector label {
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.chapter-selector select {
    flex: 1;
    min-width: 250px;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    cursor: pointer;
    background: var(--bg-primary);
    font-family: var(--font-sans);
    transition: all var(--transition-base);
}

.chapter-selector select:hover {
    border-color: var(--border-hover);
}

.chapter-selector select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ==================== PROBLEMS GRID ==================== */
.problems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}

.problem-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all var(--transition-base);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.problem-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-500), var(--secondary-500));
    transform: scaleY(0);
    transition: transform var(--transition-base);
}

.problem-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-200);
}

.problem-card:hover::before {
    transform: scaleY(1);
}

.problem-card h4 {
    color: var(--primary-600);
    margin-bottom: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.problem-card p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
}

.difficulty-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.difficulty-easy {
    background: var(--success-50);
    color: var(--success-600);
}

.difficulty-medium {
    background: var(--warning-50);
    color: var(--warning-600);
}

.difficulty-hard {
    background: var(--danger-50);
    color: var(--danger-600);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-4);
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: var(--space-4);
    color: var(--text-tertiary);
}

.empty-state h3 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

/* ==================== VIDEO LIST ==================== */
.video-list {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.video-item {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    transition: background var(--transition-base);
}

.video-item:hover {
    background: var(--bg-secondary);
}

.video-item:last-child {
    border-bottom: none;
}

.video-info {
    flex: 1;
}

.video-info h4 {
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-weight: var(--font-semibold);
}

.video-info p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.video-link {
    padding: var(--space-3) var(--space-5);
    background: var(--primary-500);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.video-link:hover {
    background: var(--primary-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== TESTS & EXAMS GRID ==================== */
.tests-grid, .exams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-6);
}

.test-card, .exam-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow);
    transition: all var(--transition-base);
    border: 1px solid var(--border-color);
}

.test-card:hover, .exam-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-200);
}

.test-card h3, .exam-card h3 {
    color: var(--primary-600);
    margin-bottom: var(--space-4);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}

.test-card p, .exam-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    line-height: var(--leading-relaxed);
}

.test-meta {
    display: flex;
    gap: var(--space-5);
    margin: var(--space-4) 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.test-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.start-test-btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--success-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: var(--font-semibold);
    cursor: pointer;
    margin-top: var(--space-4);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.start-test-btn:hover {
    background: var(--success-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== PROGRESS DASHBOARD ==================== */
.progress-dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-6);
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all var(--transition-base);
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-600);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-600);
}

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--secondary-600);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-600);
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-number {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.chart-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-6);
    color: var(--text-primary);
}

.achievement-section h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 117px; /* Below header (64px) + nav (53px) */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30; /* Below header (50) and nav (40) */
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-4);
    padding-top: var(--space-6);
}

.modal-overlay {
    position: absolute;
    top: -117px; /* Extend overlay to cover from top of viewport */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 1000px;
    width: 100%;
    max-height: calc(100vh - 137px); /* Account for header + nav + padding */
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    z-index: 1;
    animation: modalSlideDown 0.3s ease-out;
}

/* New animation for modal appearing from below header */
@keyframes modalSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    right: var(--space-6);
    top: var(--space-6);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-3xl);
    font-weight: var(--font-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    line-height: 1;
}

.close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

#modalTitle {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--primary-600);
    margin-bottom: var(--space-6);
    padding-right: var(--space-12);
}

.problem-display {
    display: grid;
    gap: var(--space-8);
}

.problem-question h4 {
    margin-bottom: var(--space-4);
    color: var(--text-primary);
    font-weight: var(--font-semibold);
}

.image-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
}

.image-container img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-lg);
}

.answer-section {
    background: var(--bg-secondary);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
}

.input-group {
    margin-bottom: var(--space-6);
}

.input-group label {
    display: block;
    margin-bottom: var(--space-3);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.input-group input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: all var(--transition-base);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.answer-reveal {
    text-align: center;
}

.answer-reveal .image-container {
    margin-bottom: var(--space-4);
    position: relative;
}

#answerImage {
    transition: filter 0.5s ease;
}

#answerImage.blurred {
    filter: blur(20px);
}

.blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    opacity: 1;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

#answerImage:not(.blurred) ~ .blur-overlay {
    opacity: 0;
}

.blur-overlay p {
    font-weight: var(--font-medium);
}

#checkAnswerBtn {
    padding: var(--space-3) var(--space-8);
    display: inline-flex;
}

.solution-feedback {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--success-50);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-500);
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--success-600);
}

.feedback-content svg {
    flex-shrink: 0;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-color);
}

/* ==================== FOOTER ==================== */
.app-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: var(--space-12) var(--space-6) var(--space-6);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.footer-section h4 {
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.footer-section p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: var(--space-2);
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: color var(--transition-base);
}

.footer-section a:hover {
    color: var(--primary-600);
}

.social-links {
    display: flex;
    gap: var(--space-3);
}

.social-links a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.social-links a:hover {
    background: var(--primary-500);
    color: white;
    transform: translateY(-2px);
}

.footer-bottom {
    max-width: 1400px;
    margin: 0 auto;
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-bottom p {
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-tooltip);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
}

.toast {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary-500);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left-color: var(--success-500);
}

.toast.error {
    border-left-color: var(--danger-500);
}

.toast.warning {
    border-left-color: var(--warning-500);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
    color: var(--text-primary);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 1024px) {
    .user-stats {
        display: none;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .auth-container {
        padding: var(--space-8) var(--space-6);
    }
    
    .header-content {
        padding: var(--space-3) var(--space-4);
        gap: var(--space-3);
    }
    
    .header-left {
        flex: 1;
    }
    
    .logo {
        font-size: var(--text-lg);
        gap: var(--space-2);
    }
    
    .logo svg {
        width: 28px;
        height: 28px;
    }
    
    .header-right {
        gap: var(--space-3);
    }
    
    .user-stats {
        display: none;
    }
    
    .header-actions {
        gap: var(--space-2);
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
    }
    
    .user-menu-btn {
        padding: var(--space-1) var(--space-2);
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: var(--text-xs);
    }
    
    .user-name {
        display: none;
    }
    
    .user-menu-btn svg {
        display: none;
    }
    
    .nav-tabs {
        padding: 0 var(--space-4);
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .nav-tab {
        padding: var(--space-3) var(--space-3);
        font-size: var(--text-sm);
        flex-shrink: 0;
        min-width: auto;
    }
    
    .nav-tab span {
        display: none;
    }
    
    .nav-tab svg {
        margin: 0;
    }
    
    .main-content {
        padding: var(--space-6) var(--space-4);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }
    
    .section-header h2 {
        font-size: var(--text-xl);
    }
    
    .search-box {
        width: 100%;
    }
    
    .chapter-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .chapter-selector select {
        width: 100%;
    }
    
    .problems-grid, .tests-grid, .exams-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: var(--space-2);
        padding: var(--space-6) var(--space-4);
        max-height: 95vh;
    }
    
    #modalTitle {
        font-size: var(--text-xl);
    }
    
    .close-btn {
        right: var(--space-4);
        top: var(--space-4);
    }
    
    .modal-actions {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .modal-actions button {
        width: 100%;
    }
    
    .ad-space {
        font-size: var(--text-sm);
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: var(--space-2) var(--space-3);
    }
    
    .logo {
        font-size: var(--text-base);
        gap: var(--space-2);
    }
    
    .logo svg {
        width: 24px;
        height: 24px;
    }
    
    .logo span {
        font-size: var(--text-base);
    }
    
    .icon-btn {
        width: 32px;
        height: 32px;
    }
    
    .icon-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .user-avatar {
        width: 26px;
        height: 26px;
    }
    
    .nav-tab {
        padding: var(--space-2) var(--space-3);
        min-width: 44px;
    }
    
    .nav-tab svg {
        width: 20px;
        height: 20px;
    }
    
    .section-header h2 {
        font-size: var(--text-xl);
    }
    
    .stat-card {
        padding: var(--space-4);
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
    }
    
    .stat-number {
        font-size: var(--text-2xl);
    }
    
    .main-content {
        padding: var(--space-5) var(--space-3);
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .app-header, .nav-tabs, .ad-space, .app-footer, .modal-actions {
        display: none !important;
    }
    
    .main-content {
        max-width: 100%;
        padding: 0;
    }
    
    .problem-card, .test-card, .exam-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: var(--gray-400);
        --shadow: none;
        --shadow-md: none;
        --shadow-lg: none;
    }
    
    .problem-card, .test-card, .exam-card {
        border: 2px solid var(--border-color);
    }
}

/* ==================== UTILITY CLASSES ==================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* Modal Background */
.modal {
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(0,0,0,0.6); 
}

/* Modal Box */
.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: 80%;
  max-width: 600px;
  font-family: sans-serif;
  line-height: 1.6;
}

/* Close Button */
.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover { color: #000; }
