:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #f43f5e;
    --accent: #10b981;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 20px;
}

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

body {
    background: var(--background);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 4rem;
}

.header-content h1 {
    font-size: 2.2rem;
    margin-bottom: 0.2rem;
}

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

.portal-btn {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.portal-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

.achievements-btn {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievements-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 30px rgba(245, 158, 11, 0.4);
}

/* Tabs / Switcher */
.lesson-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--glass);
    padding: 0.5rem;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow);
}

.tab-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 25px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Content Area */
.content-wrapper {
    position: relative;
    min-height: 500px;
}

.pane {
    display: none;
    animation: slideUp 0.5s ease-out;
}

.pane.active {
    display: block;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.explanation-section h2, .exercise-section h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.8rem;
}

.explanation-section p {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 1.2rem;
}

.concept {
    background: #eff6ff;
    padding: 1.5rem;
    border-radius: 15px;
    border-right: 5px solid var(--primary);
    color: #1e40af;
}
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 1.5rem 0;
}

.cube {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 4px 4px 0px #4338ca;
    position: relative;
    transition: transform 0.3s;
}

.cube:hover {
    transform: translateY(-5px);
    box-shadow: 6px 6px 0px #4338ca;
}

.cube-stack {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

/* Exercise Items */
.exercise-item {
    background: #f1f5f9;
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    border-right: 5px solid var(--primary);
    transition: all 0.3s;
}

.exercise-item:hover {
    transform: translateX(-5px);
    background: #e2e8f0;
}

.input-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

input[type="number"], input[type="text"] {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--primary);
}

.check-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.check-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Lesson Selector */
.lesson-selector {
    margin-bottom: 1.5rem;
    background: var(--glass);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.lesson-selector select {
    padding: 0.5rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: white;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    outline: none;
}

/* Place Value Table */
.place-value-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.place-value-table th {
    background: var(--primary);
    color: white;
    padding: 1rem;
    font-size: 1.1rem;
}

.place-value-table td {
    border: 1px solid #e2e8f0;
    padding: 1rem;
    text-align: center;
    vertical-align: top;
}

.visual-repr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    min-height: 80px;
}

.mini-cube { width: 15px; height: 15px; background: #6366f1; border-radius: 2px; }
.mini-rod { width: 6px; height: 40px; background: #f43f5e; border-radius: 2px; }
.mini-square { width: 30px; height: 30px; background: #10b981; border-radius: 2px; border: 1px solid #059669; }
.mini-thousand { width: 40px; height: 40px; background: #8b5cf6; border-radius: 4px; box-shadow: 2px 2px 0 #6d28d9; }

/* Lesson 3 Specifics */
.underlined {
    text-decoration: underline;
    text-decoration-color: var(--secondary);
    text-decoration-thickness: 3px;
    font-weight: 800;
    color: var(--secondary);
}

.expanded-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.expanded-form input {
    width: 70px !important;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container { padding: 1rem; }
    header h1 { font-size: 1.8rem; }
    .card { padding: 1.5rem; }
}

/* Decorative Background */
.bg-blob {
    position: fixed;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.4;
    border-radius: 50%;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-light);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    right: -50px;
}

/* Curriculum Map & Views */
.view { animation: fadeIn 0.5s ease-out; position: relative; }
.view.hidden { display: none; }

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 3rem;
    padding: 1rem;
}

.chapter-card {
    background: white;
    border-radius: 30px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
    border: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.chapter-card:hover {
    transform: translateY(-15px);
    box-shadow: 0 30px 60px rgba(0,0,0,0.1);
}

.chapter-header {
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    text-align: center;
    position: relative;
}

.chapter-card:nth-child(2n) .chapter-header { background: linear-gradient(135deg, #f43f5e, #fb7185); }
.chapter-card:nth-child(3n) .chapter-header { background: linear-gradient(135deg, #10b981, #34d399); }
.chapter-card:nth-child(4n) .chapter-header { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.chapter-card:nth-child(5n) .chapter-header { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

.chapter-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: block;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.2));
}

.chapter-header h2 {
    margin: 0;
    border: none;
    font-size: 1.6rem;
    color: white;
}

.lesson-list {
    padding: 1.5rem;
    background: white;
}

.lesson-link {
    padding: 1.2rem;
    background: #f8fafc;
    border-radius: 20px;
    margin-bottom: 0.8rem;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.lesson-link:hover {
    background: #eff6ff;
    border-color: var(--primary);
    transform: translateX(-5px);
}

.lesson-link.completed {
    background: #ecfdf5;
    border-color: #10b981;
}

.lesson-link.completed::after {
    content: '✅';
    margin-right: auto;
}

/* Achievements Grid */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.badge-card {
    background: white;
    padding: 2rem;
    border-radius: 30px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    opacity: 0.5;
    filter: grayscale(1);
}

.badge-card.unlocked {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.05);
    border: 3px solid #fcd34d;
}

.badge-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.badge-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.badge-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.back-btn {
    background: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 800;
    color: var(--primary);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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