:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --secondary: #F59E0B;
    --secondary-light: #FCD34D;
    --success: #10B981;
    --danger: #EF4444;
    --background: #F3F4F6;
    --surface: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);
    
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Extra Variables */
    --gradient-1: linear-gradient(135deg, #4F46E5, #3B82F6);
    --gradient-gold: linear-gradient(135deg, #FCD34D, #F59E0B);
    --dark-text: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    background-image: radial-gradient(circle at top right, #E0E7FF 0%, transparent 40%),
                      radial-gradient(circle at bottom left, #FEF3C7 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
}

#app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    padding: 15px 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

.logo { display: flex; align-items: center; gap: 15px; }
.logo-icon { font-size: 2.5rem; animation: float 3s ease-in-out infinite; }
.logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

.nav-menu { display: flex; gap: 15px; }
.nav-btn {
    background: none; border: none; padding: 10px 20px;
    font-size: 1.1rem; font-weight: 700; color: var(--text-muted);
    border-radius: var(--radius-full); cursor: pointer; transition: 0.2s;
}
.nav-btn:hover { background: rgba(79, 70, 229, 0.05); color: var(--primary); }
.nav-btn.active { background: var(--primary); color: white; box-shadow: var(--shadow-md); }

/* Views */
.view { display: none; opacity: 0; transform: translateY(10px); transition: 0.3s; }
.view.active { display: block; opacity: 1; transform: translateY(0); }
.hidden { display: none !important; }

/* Dashboard */
.hero-section {
    background: linear-gradient(135deg, #FCD34D, #F59E0B);
    border-radius: var(--radius-lg); padding: 40px;
    display: flex; justify-content: space-between; align-items: center;
    color: #fff; box-shadow: var(--shadow-md); margin-bottom: 40px;
}
.hero-content h2 { font-size: 2.2rem; font-weight: 800; margin-bottom: 10px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); }
.hero-content p { font-size: 1.2rem; font-weight: 500; opacity: 0.9; }
.hero-visual .mascot { 
    font-size: 8rem; 
    display: inline-block;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2));
    animation: bounce 2s infinite; 
}

.chapter-block { margin-bottom: 40px; }
.chapter-title {
    font-size: 1.8rem; color: var(--text-main);
    border-right: 5px solid var(--primary); padding-right: 15px; margin-bottom: 20px;
}
.lessons-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 25px;
}
.lesson-card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 30px 20px;
    text-align: center; cursor: pointer; box-shadow: var(--shadow-sm);
    transition: 0.3s; border: 2px solid transparent;
}
.lesson-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.lesson-card .icon { font-size: 4rem; margin-bottom: 15px; display: inline-block; transition: 0.3s; }
.lesson-card:hover .icon { transform: scale(1.1); }
.lesson-card h4 { font-size: 1.4rem; color: var(--text-main); }

/* Lesson View */
.lesson-header { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.btn-back {
    background: white; border: none; padding: 10px 20px; border-radius: var(--radius-full);
    font-size: 1.1rem; font-weight: 700; color: var(--text-main); cursor: pointer;
    box-shadow: var(--shadow-sm); transition: 0.2s;
}
.btn-back:hover { background: var(--primary); color: white; }
#lesson-title-display { font-size: 2rem; color: var(--primary); flex-grow: 1; }
.lesson-icon { font-size: 3rem; }

.tabs-control { display: flex; gap: 15px; margin-bottom: 30px; background: rgba(255,255,255,0.5); padding: 10px; border-radius: var(--radius-lg); }
.tab-btn {
    flex: 1; background: transparent; border: none; padding: 15px;
    font-size: 1.3rem; font-weight: 700; color: var(--text-muted);
    border-radius: var(--radius-md); cursor: pointer; transition: 0.2s;
}
.tab-btn.active { background: white; color: var(--primary); box-shadow: var(--shadow-md); }

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

/* Explanation Blocks */
.content-block {
    background: white; border-radius: var(--radius-lg); padding: 25px;
    margin-bottom: 25px; box-shadow: var(--shadow-sm); border-right: 4px solid var(--primary-light);
}
.content-block.definition .term { font-size: 1.5rem; color: var(--primary); margin-bottom: 10px; display: block; font-weight: 800; }
.content-block.definition .text { font-size: 1.2rem; line-height: 1.8; }
.content-block.info .text { font-size: 1.2rem; line-height: 1.8; }

.content-block.list h4 { font-size: 1.4rem; color: var(--primary); margin-bottom: 15px; }
.list-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.list-item {
    background: var(--background); padding: 15px; border-radius: var(--radius-md);
    display: flex; align-items: flex-start; gap: 15px; transition: 0.2s;
}
.list-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); background: #EEF2FF; }
.list-item .item-icon { font-size: 2rem; }
.list-item h5 { font-size: 1.2rem; color: var(--text-main); margin-bottom: 5px; }

.content-block.comparison .compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.compare-card { background: #FEF3C7; padding: 20px; border-radius: var(--radius-md); text-align: center; }
.compare-card:nth-child(2) { background: #E0E7FF; }
.compare-card h4 { font-size: 1.4rem; color: var(--primary); margin: 10px 0; }
.compare-card p { font-size: 1.1rem; margin-bottom: 10px; }
.compare-card small { color: var(--text-muted); }

/* Quiz */
.quiz-container { background: white; border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow-md); text-align: center; }
.question-text { font-size: 1.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 30px; }
.options-grid { display: grid; grid-template-columns: 1fr; gap: 15px; max-width: 600px; margin: 0 auto; }
.option-btn {
    background: var(--background); border: 2px solid transparent; padding: 20px;
    font-size: 1.2rem; font-weight: 700; border-radius: var(--radius-md);
    cursor: pointer; transition: 0.2s; text-align: right;
}
.option-btn:hover { background: #EEF2FF; border-color: var(--primary-light); }
.option-btn.correct { background: #D1FAE5; border-color: var(--success); color: #065F46; }
.option-btn.wrong { background: #FEE2E2; border-color: var(--danger); color: #991B1B; }

.quiz-feedback { margin-top: 25px; font-size: 1.5rem; font-weight: 800; min-height: 40px; }
.btn-next {
    margin-top: 30px; background: linear-gradient(135deg, #4F46E5, #3B82F6); color: white;
    border: none; padding: 15px 40px; font-size: 1.3rem; font-weight: 800;
    border-radius: var(--radius-full); cursor: pointer; box-shadow: var(--shadow-md);
    transition: 0.2s; display: none;
}
.btn-next:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }

.quiz-completed h3 { font-size: 2.5rem; color: var(--success); margin-bottom: 15px; }

/* Animations */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    #app-container { padding: 10px; }
    .app-header { padding: 10px 15px; flex-direction: column; gap: 15px; text-align: center; }
    .nav-menu { width: 100%; justify-content: center; }
    .hero-section { flex-direction: column; text-align: center; padding: 30px 20px; }
    .hero-content h2 { font-size: 1.8rem; }
    .hero-visual .mascot { font-size: 4rem; }
    .content-block.comparison .compare-grid { grid-template-columns: 1fr; }
    #lesson-title-display { font-size: 1.5rem; }
    .tab-btn { font-size: 1.1rem; padding: 10px; }
    .question-text { font-size: 1.4rem; }
}

/* --- Study Map (Roadmap) --- */
.study-map {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 0;
}
.study-map::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 6px;
    background: var(--gradient-1);
    transform: translateX(-50%);
    border-radius: 10px;
    opacity: 0.3; /* Make it subtle so it doesn't clash with text if they overlap */
}

.map-chapter {
    margin-bottom: 4rem;
    position: relative;
}

.map-chapter-title {
    background: #FFFFFF;
    color: var(--dark-text);
    padding: 0.8rem 2rem;
    border-radius: 30px;
    display: block;
    width: fit-content;
    max-width: 95%;
    margin: 0 auto 2.5rem auto;
    position: relative;
    z-index: 2;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    font-weight: 800;
    border: 3px solid var(--primary);
    font-size: 1.4rem;
    text-align: center;
    white-space: normal; /* Allow wrapping on very small screens */
    word-wrap: break-word;
}

.map-lessons {
    display: block;
}

.map-lesson-card {
    position: relative;
    width: calc(50% - 40px);
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 2px solid transparent;
}

.map-lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 184, 148, 0.3);
    border-color: var(--secondary-color);
}

.map-lesson-card::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    background: white;
    border: 5px solid var(--secondary-color);
    border-radius: 50%;
    z-index: 2;
}

/* RTL Layout: right is visually start, left is end */
/* Odd = Right side of the center line (so it is on the right visually) */
.map-lesson-card:nth-child(odd) {
    margin-right: 0;
    margin-left: auto;
}
/* The center line is to the left of the right card, so dot goes on the left side of the card */
.map-lesson-card:nth-child(odd)::after {
    left: -53px; 
    transform: translateY(-50%);
}

/* Even = Left side of the center line */
.map-lesson-card:nth-child(even) {
    margin-right: auto;
    margin-left: 0;
}
/* The center line is to the right of the left card, so dot goes on the right side of the card */
.map-lesson-card:nth-child(even)::after {
    right: -53px;
    transform: translateY(-50%);
}

.map-lesson-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    background: rgba(108, 92, 231, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.map-lesson-info {
    flex-grow: 1;
}
.map-lesson-info h4 {
    margin-bottom: 0.5rem;
    color: var(--dark-text);
}

.lesson-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    background: #f1f2f6;
    color: var(--text-color);
    font-weight: bold;
    display: inline-block;
}
.lesson-status.completed {
    background: rgba(0, 184, 148, 0.2);
    color: var(--success);
}

@media (max-width: 768px) {
    .study-map::before {
        left: auto;
        right: 30px;
        transform: none;
    }
    .map-chapter-title {
        margin: 0 45px 2rem auto; /* Align near the vertical line on the right */
        font-size: 1.2rem;
        padding: 0.6rem 1.5rem;
    }
    .map-lesson-card {
        width: calc(100% - 70px);
        margin-right: 70px !important;
        margin-left: 0 !important;
    }
    .map-lesson-card::after {
        left: auto !important;
        right: -48px !important;
        transform: translateY(-50%) !important;
    }
}

/* --- Achievements View --- */
.achievements-container {
    padding: 2rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.stats-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 3rem;
    justify-content: center;
}
.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    min-width: 250px;
}
.stat-icon {
    font-size: 3rem;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-info h4 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}
.stat-info p {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark-text);
}
.badges-container h3 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--dark-text);
}
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
    justify-items: center;
}
.badge-card {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: var(--shadow);
    filter: grayscale(100%);
    opacity: 0.5;
    transition: all 0.3s;
    width: 100%;
}
.badge-card.unlocked {
    filter: grayscale(0%);
    opacity: 1;
    background: linear-gradient(135deg, white, rgba(253, 234, 204, 0.4));
    border: 2px solid gold;
    transform: scale(1.05);
}
.badge-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}
.badge-title {
    font-weight: bold;
    color: var(--dark-text);
    font-size: 0.9rem;
}

