:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #14b8a6;
    --background: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(to top, #e18ebb, #8b4fb8, #3b177d) fixed;
    background-size: cover;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Gradients */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
}

body::before {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary-dark) 0%, transparent 70%);
}

body::after {
    bottom: -10%;
    right: -10%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, transparent 70%);
}

/* Common Classes */
.hidden { display: none !important; }
.screen {
    min-height: 100vh;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.screen.active {
    display: flex;
    opacity: 1;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-light);
    color: var(--primary-light);
}
.btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
}
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; border-radius: 8px; }
.btn-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--glass-border);
    font-size: 1.2rem;
}

.gradient-text {
    background: linear-gradient(to right, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    outline: none;
}
.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 10px;
    text-align: center;
}

/* ================= LOGIN SCREEN ================= */
#login-screen {
    align-items: center;
    justify-content: center;
}
.login-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}
.login-box {
    padding: 40px 30px;
    position: relative;
    z-index: 2;
}
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.logo-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: white;
}
.logo-container h1 { font-size: 1.8rem; font-weight: 700; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 0.95rem; }

/* Decorative Blobs */
.decorative-blob {
    position: absolute;
    filter: blur(40px);
    z-index: 1;
    border-radius: 50%;
    animation: float 10s infinite alternate;
}
.blob-1 {
    width: 150px; height: 150px;
    background: var(--primary);
    top: -50px; right: -50px;
}
.blob-2 {
    width: 120px; height: 120px;
    background: var(--secondary);
    bottom: -30px; left: -30px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(20px, 30px) rotate(20deg); }
}

/* ================= MAIN APP ================= */
#app-screen {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: calc(100vh - 40px);
}
.logo-container.sm .logo-icon {
    width: 40px; height: 40px; font-size: 20px; border-radius: 10px;
}
.logo-container.sm h2 { font-size: 1.4rem; }

.nav-menu {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}
.nav-item .icon { font-size: 1.4rem; }
.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
    color: white;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), transparent);
    border-left: 4px solid var(--primary);
}

.nav-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 45px; height: 45px;
    border-radius: 12px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700;
}
.user-details h4 { font-size: 1rem; margin: 0; }
.user-details span { font-size: 0.8rem; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.tab-pane { display: none; animation: fadeIn 0.4s ease; }
.tab-pane.active { display: block; }

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

.page-header {
    margin-bottom: 30px;
}
.page-header h1 { font-size: 2.2rem; margin-bottom: 8px; }
.page-header p { color: var(--text-muted); font-size: 1.1rem; }

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-icon {
    width: 60px; height: 60px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}
.stat-icon.purple { background: rgba(99, 102, 241, 0.1); color: var(--primary-light); }
.stat-icon.green { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-info h3 { font-size: 1.8rem; margin: 0 0 4px 0; }
.stat-info p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.section-title-wrap {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.section-title-wrap h2 { font-size: 1.5rem; }

/* Lessons Grid */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}
.lesson-card {
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    background: rgba(30, 41, 59, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}
.lesson-card:hover {
    transform: translateY(-5px);
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.lesson-cover {
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; color: rgba(255,255,255,0.1);
}
.lesson-body { padding: 20px; }
.lesson-cat {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.lesson-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.lesson-meta {
    display: flex; align-items: center; gap: 15px; color: var(--text-muted); font-size: 0.9rem;
}
.lesson-status {
    position: absolute; top: 15px; right: 15px;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}
.status-completed { color: var(--success); }
.status-new { color: var(--warning); }

/* Category Filter */
.category-filter {
    display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 30px;
}
.cat-btn {
    padding: 8px 16px; border-radius: 20px; border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; transition: all 0.2s;
}
.cat-btn:hover { background: rgba(255,255,255,0.1); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); }

/* Ranking */
.ranking-container { padding: 0; overflow: hidden; }
.ranking-header {
    display: grid; grid-template-columns: 80px 1fr 100px 100px;
    padding: 16px 24px; border-bottom: 1px solid var(--glass-border);
    font-weight: 600; color: var(--text-muted);
}
.ranking-item {
    display: grid; grid-template-columns: 80px 1fr 100px 100px;
    padding: 16px 24px; border-bottom: 1px solid rgba(255,255,255,0.02);
    align-items: center; transition: background 0.2s;
}
.ranking-item:hover { background: rgba(255,255,255,0.02); }
.rank-num {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
}
.rank-1 .rank-num { background: #fbbf24; color: #000; }
.rank-2 .rank-num { background: #94a3b8; color: #000; }
.rank-3 .rank-num { background: #b45309; color: #fff; }
.rank-user { display: flex; align-items: center; gap: 12px; }
.rank-avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); }
.rank-score { font-weight: 700; font-size: 1.1rem; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(45, 15, 65, 0.6); backdrop-filter: blur(10px);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal-content {
    width: 95%; max-width: 1200px; max-height: 90vh;
    display: flex; flex-direction: column;
}
.viewer-header, .quiz-header {
    padding: 20px 24px; border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; gap: 20px;
}
.viewer-header h2, .quiz-header h2 { margin: 0; flex: 1; font-size: 1.4rem; }
.viewer-body {
    padding: 30px; overflow-y: auto; flex: 1; min-height: 400px;
}
.viewer-footer, .quiz-footer {
    padding: 20px 24px; border-top: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
}
.viewer-slide img {
    max-width: 100%; border-radius: 12px; margin-bottom: 20px;
}
.viewer-slide .content {
    font-size: 1.1rem; line-height: 1.8; color: #e2e8f0;
}
.viewer-slide h2, .viewer-slide h3 { color: white; margin: 20px 0 10px 0; }

/* Quiz Styles */
.quiz-viewer { max-width: 700px; }
.quiz-body { padding: 40px 30px; }
.quiz-body h3 { font-size: 1.4rem; margin-bottom: 30px; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 15px; }
.quiz-option {
    padding: 16px 20px;
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 15px;
}
.quiz-option:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}
.quiz-option.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}
.opt-label {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--surface); display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--text-muted);
}
.quiz-option.selected .opt-label {
    background: var(--primary); color: white;
}

/* Toast */
.toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    padding: 12px 24px; border-radius: 8px; background: #333; color: white;
    font-weight: 500; font-size: 0.95rem; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease forwards;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Mobile */
@media (max-width: 768px) {
    #app-screen { flex-direction: column; padding: 10px; height: auto; }
    .sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; padding: 15px; }
    .nav-menu { margin: 0; flex-direction: row; gap: 5px; flex: 1; justify-content: center; }
    .nav-item { padding: 10px; }
    .nav-item span:last-child { display: none; }
    .nav-footer { margin: 0; padding: 0; border: none; }
    .user-details { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .ranking-header, .ranking-item { grid-template-columns: 60px 1fr 80px 0px; }
    .ranking-header .rank-col:last-child, .ranking-item .rank-col:last-child { display: none; }
}
