:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --dark: #2D3436;
    --light: #F9F9F9;
    --white: #FFFFFF;
    --success: #00B894;
    --warning: #FDCB6E;
    
    --shadow: 0 10px 20px rgba(0,0,0,0.08);
    --shadow-hover: 0 15px 30px rgba(108, 92, 231, 0.2);
    --radius: 20px;
    
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Nunito', sans-serif;
}

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

body {
    font-family: var(--font-ar);
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.6;
    background-image: radial-gradient(circle at top right, rgba(162, 155, 254, 0.1), transparent 400px),
                      radial-gradient(circle at bottom left, rgba(0, 206, 201, 0.1), transparent 400px);
    min-height: 100vh;
}

/* Typography */
.en-text {
    font-family: var(--font-en);
    direction: ltr;
    display: inline-block;
}

/* Header */
.app-header {
    background: var(--white);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
}
.logo span {
    color: var(--dark);
    font-weight: 700;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.home-btn, .back-btn {
    background: var(--primary-light);
    color: var(--white);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
}
.home-btn:hover, .back-btn:hover {
    background: var(--primary);
    transform: translateY(-2px);
}

/* Main Container */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 5%;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}
.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

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

/* Dashboard */
.main-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}
.subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 3rem;
}

.book-selection-cards {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.book-card {
    background: var(--white);
    width: 300px;
    padding: 3rem 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}
.book-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

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

.book-card h2 {
    font-family: var(--font-en);
    color: var(--dark);
    margin-bottom: 0.5rem;
}
.book-card p {
    color: var(--primary);
    font-weight: 700;
}

/* Units View */
.view-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed #eee;
}

.units-container {
    display: block;
    width: 100%;
}

.units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.unit-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    border-right: 5px solid var(--secondary);
}
.unit-card:hover {
    transform: scale(1.03);
}

.unit-title {
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

/* Unit Grouping */
.unit-section-group {
    margin-bottom: 3rem;
    width: 100%;
    grid-column: 1 / -1;
}

.unit-main-title {
    font-size: 1.8rem;
    color: var(--primary);
    margin: 2rem 0 1.5rem 0;
    padding: 0.5rem 1.5rem;
    background: var(--white);
    border-radius: 15px;
    display: inline-block;
    box-shadow: var(--shadow);
    border-right: 8px solid var(--accent);
}

.lessons-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 2rem;
}

/* Lesson Content Layout */
.lesson-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.lesson-section {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.section-title {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 25px;
    background: var(--accent);
    border-radius: 4px;
}

/* Clickable Text for TTS */
.clickable-text {
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: inline-block;
}
.clickable-text:hover {
    color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
    border-radius: 5px;
    padding: 0 5px;
}
.clickable-text::after {
    content: '🔊';
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.5;
}

/* Characters Section */
.characters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media(min-width: 768px) {
    .characters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.char-card {
    display: flex;
    background: var(--light);
    border-radius: 15px;
    padding: 1.5rem;
    gap: 1rem;
    border: 1px solid #eee;
}
.char-bubble {
    background: var(--white);
    padding: 1rem;
    border-radius: 15px;
    border-top-left-radius: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    flex: 1;
}
.char-text {
    font-family: var(--font-en);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

/* Vocabulary Grid */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.vocab-item {
    background: var(--primary-light);
    color: var(--white);
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.vocab-item:hover {
    transform: scale(1.05);
    background: var(--primary);
}
.vocab-en { font-family: var(--font-en); font-weight: 800; }
.vocab-ar { font-weight: 700; }

/* Grammar Tables */
.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.grammar-table th, .grammar-table td {
    padding: 1rem;
    border: 1px solid #eee;
    text-align: right;
}
.grammar-table th {
    background: var(--secondary);
    color: var(--white);
}

.grammar-example {
    background: var(--light);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-right: 4px solid var(--accent);
}

/* Quiz Section */
.quiz-question {
    margin-bottom: 2rem;
    background: var(--light);
    padding: 1.5rem;
    border-radius: 10px;
}
.q-text {
    font-family: var(--font-en);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    direction: ltr;
}
.q-options {
    display: flex;
    gap: 1rem;
    direction: ltr;
}
.q-option {
    background: var(--white);
    border: 2px solid var(--primary-light);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-family: var(--font-en);
    font-weight: 700;
    color: var(--primary);
}
.q-option:hover {
    background: var(--primary-light);
    color: var(--white);
}
.q-option.correct {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}
.q-option.wrong {
    background: #FF7675;
    border-color: #FF7675;
    color: var(--white);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 52, 54, 0.95);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.2rem;
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transition: opacity 0.3s;
}
