:root {
    --primary: #4A90D9;
    --primary-light: #6BA3E0;
    --primary-dark: #3570B0;
    --secondary: #2ECC71;
    --secondary-light: #58D68D;
    --accent: #F39C12;
    --accent-light: #F5B041;
    --bg: #F5F6FA;
    --bg-card: #FFFFFF;
    --bg-dark: #2C3E50;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --text-white: #FFFFFF;
    --danger: #E74C3C;
    --success: #27AE60;
    --border: #E0E4E8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
}

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

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-white);
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.header-logo-icon {
    font-size: 1.75rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.stat-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    transition: background var(--transition);
}
.header-user:hover { background: rgba(255,255,255,0.15); }

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,0.3); }

/* ===== AUTH FORMS ===== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-white);
    width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary); color: white; }

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

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

.error-msg {
    background: #FDEDED;
    color: var(--danger);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: none;
}

/* ===== MAIN LAYOUT ===== */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== WELCOME SECTION ===== */
.welcome-section {
    background: linear-gradient(135deg, var(--primary), #6C5CE7);
    color: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.welcome-mascot {
    font-size: 4rem;
    flex-shrink: 0;
}

.welcome-text h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.welcome-text p {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* ===== PROGRESS BAR ===== */
.progress-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.progress-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.progress-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.progress-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.progress-card-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.progress-bar-container {
    background: var(--border);
    border-radius: 10px;
    height: 10px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
}

/* ===== MODULE CARDS ===== */
.section-title {
    font-size: 1.35rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.module-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.module-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
}
.module-card.locked:hover {
    transform: none;
    box-shadow: var(--shadow);
    border-color: transparent;
}

.module-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.module-icon {
    font-size: 2.25rem;
    flex-shrink: 0;
}

.module-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.module-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    gap: 1rem;
    margin-top: 0.15rem;
}

.module-description {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.module-story {
    background: #F0F4FF;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary);
}

.module-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.module-progress-text {
    font-size: 0.8rem;
    color: var(--text-light);
}

.lock-overlay {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.25rem;
}

/* ===== LESSON VIEW ===== */
.lesson-view {
    max-width: 800px;
    margin: 0 auto;
}

.lesson-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn-back {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition);
}
.btn-back:hover { border-color: var(--primary); background: #F0F4FF; }

.lesson-title {
    font-size: 1.4rem;
}

.lesson-xp {
    margin-left: auto;
    background: #FFF8E1;
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Content sections */
.content-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.content-intro {
    font-size: 1.05rem;
    line-height: 1.7;
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
}

.content-analogy {
    border: 2px solid #E8F4FD;
    background: #F0F9FF;
}

.analogy-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}

.analogy-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.analogy-real {
    text-align: right;
    font-weight: 600;
    color: var(--accent);
}

.analogy-arrow {
    color: var(--text-light);
    font-size: 1.25rem;
}

.analogy-tech {
    font-weight: 600;
    color: var(--primary);
}

.analogy-detail {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
}

.content-info {
    background: #FFF8E1;
    border: 2px solid #FFE082;
}

.info-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.content-code {
    background: var(--bg-dark);
    color: #ECF0F1;
    border-radius: var(--radius);
    overflow: hidden;
}

.code-header {
    background: rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.code-block {
    padding: 1rem;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.code-explanation {
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.05);
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
    color: #BDC3C7;
}

.content-summary {
    background: linear-gradient(135deg, #E8F8F5, #D5F5E3);
    border: 2px solid var(--secondary-light);
}

.summary-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--success);
}

/* ===== EXERCISES ===== */
.exercise-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
}

.exercise-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.exercise-prompt {
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.options-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-item {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-item:hover { border-color: var(--primary-light); background: #F0F4FF; }
.option-item.selected { border-color: var(--primary); background: #E8F0FE; }
.option-item.correct { border-color: var(--success); background: #E8F8F0; }
.option-item.incorrect { border-color: var(--danger); background: #FDEDED; }

.option-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.exercise-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}
.exercise-textarea:focus { border-color: var(--primary); }

.exercise-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.feedback-box {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    display: none;
}

.feedback-correct {
    background: #E8F8F0;
    color: var(--success);
    border: 2px solid var(--secondary-light);
}

.feedback-incorrect {
    background: #FFF3E5;
    color: #E67E22;
    border: 2px solid #F5B041;
}

.feedback-hint {
    margin-top: 0.5rem;
    font-style: italic;
    font-size: 0.9rem;
}

/* ===== LESSON NAVIGATION ===== */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

/* ===== ACHIEVEMENTS POPUP ===== */
.achievement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.achievement-popup.show {
    transform: translate(-50%, -50%) scale(1);
}

.achievement-popup-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.achievement-popup h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.achievement-popup p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}
.overlay.show { display: block; }

/* ===== CONFETTI ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
}

/* ===== LESSONS LIST ===== */
.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid var(--border);
}

.lesson-item:hover {
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.lesson-status-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.lesson-info {
    flex: 1;
}

.lesson-info-title {
    font-weight: 600;
}

.lesson-info-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header { padding: 0 1rem; }
    .header-stats { display: none; }
    .main-content { padding: 1rem; }
    .welcome-section { flex-direction: column; text-align: center; padding: 1.5rem; }
    .welcome-mascot { font-size: 3rem; }
    .modules-grid { grid-template-columns: 1fr; }
    .analogy-pair { grid-template-columns: 1fr; text-align: center; }
    .analogy-real { text-align: center; }
    .analogy-arrow { transform: rotate(90deg); }
    .progress-overview { grid-template-columns: repeat(2, 1fr); }
    .auth-card { padding: 1.5rem; }
}

@media (max-width: 480px) {
    .progress-overview { grid-template-columns: 1fr; }
    html { font-size: 14px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse { animation: pulse 0.5s ease; }

/* ===== CODIE MASCOT ===== */
.codie-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: #F0F4FF;
    border: 2px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.codie-avatar {
    font-size: 2rem;
    flex-shrink: 0;
}

.codie-speech {
    font-size: 0.93rem;
    line-height: 1.6;
}

.codie-speech strong {
    color: var(--primary);
}

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

/* ===== STUFE 2 STYLES ===== */
.btn-nav {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}
.btn-nav:hover { background: rgba(255,255,255,0.25); }

.lang-select {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}
.lang-select option { color: #333; background: white; }

.unread-msg { background: rgba(74,144,217,0.08); border-left: 3px solid var(--primary); }

.btn-flag {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.btn-flag:hover { opacity: 1; }
