/* ألوان عصرية ومناسبة للصف الثاني */
:root {
    --bg-color: #f0f8ff;
    --primary: #4a69bd;     /* أزرق ناضج */
    --secondary: #60a3bc;   /* أزرق فاتح */
    --accent: #f6b93b;      /* أصفر دافئ */
    --success: #78e08f;     /* أخضر للنجاح */
    --text: #2f3640;
    --white: #ffffff;
    --shadow: 0 10px 20px rgba(0,0,0,0.08);
}

body {
    margin: 0;
    font-family: 'Tajawal', 'Changa', sans-serif;
    background: #f4f9f9;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* خلفية حيوية خفيفة */
.animated-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);
    opacity: 0.4;
}

.floating-items {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    margin: 0; padding: 0;
    list-style: none;
}

.floating-items li {
    position: absolute;
    display: block;
    font-size: 2rem;
    animation: floatUp 15s linear infinite;
    bottom: -100px;
}

.floating-items li:nth-child(1) { left: 10%; animation-duration: 12s; font-size: 3rem; }
.floating-items li:nth-child(2) { left: 25%; animation-duration: 9s; animation-delay: 2s; }
.floating-items li:nth-child(3) { left: 40%; animation-duration: 18s; animation-delay: 5s; }
.floating-items li:nth-child(4) { left: 60%; animation-duration: 10s; font-size: 4rem; }
.floating-items li:nth-child(5) { left: 80%; animation-duration: 14s; animation-delay: 1s; }
.floating-items li:nth-child(6) { left: 15%; animation-duration: 16s; animation-delay: 6s; }

@keyframes floatUp {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(-1200px) rotate(720deg); opacity: 0; }
}

/* تحكم بالواجهات */
.view { display: none; animation: popIn 0.4s ease-out forwards; }
.view.active-view { display: block; }
@keyframes popIn { 
    from { opacity: 0; transform: scale(0.95); } 
    to { opacity: 1; transform: scale(1); } 
}

/* الهيدر */
.app-header {
    text-align: center;
    padding: 3rem 1rem 1rem;
    color: var(--primary);
    text-shadow: 2px 2px 0px rgba(255,255,255,0.7);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 20px;
}

.header-titles {
    text-align: right;
    flex: 1;
}

.home-btn {
    background: var(--white);
    color: var(--primary);
    text-decoration: none;
    padding: 12px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    border: 3px solid var(--primary);
}

.home-btn:hover {
    background: var(--primary);
    color: var(--white);
    transform: scale(1.05) rotate(-2deg);
}

.app-header h1 { font-size: 3.5rem; margin: 0; font-family: 'Changa', sans-serif;}
.app-header p { font-size: 1.5rem; font-weight: bold; color: #353b48;}

/* شاشة تسجيل الدخول */
#login-view {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
#login-view.active-view { display: flex; }

.login-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    max-width: 450px;
    width: 100%;
    margin: 1rem auto;
    padding: 3rem 2rem;
    border-radius: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    text-align: center;
    border: 3px solid var(--white);
}

.login-box input {
    width: 90%;
    padding: 18px;
    margin-bottom: 25px;
    border: 2px solid #eee;
    border-radius: 15px;
    font-size: 1.5rem;
    font-family: inherit;
    text-align: center;
    transition: 0.3s;
    background: #fbfbfb;
}
.login-box input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 10px rgba(74, 105, 189, 0.2); }

.action-btn {
    background: var(--accent);
    color: var(--text);
    border: none;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 5px 0 #d9a022;
}
.action-btn:active { transform: translateY(5px); box-shadow: none; }
.bouncy:hover { animation: bouncy 0.5s; }
@keyframes bouncy { 0%, 100%{ transform: translateY(0); } 50%{ transform: translateY(-8px); } }

/* خريطة الدروس بطريقة الشبكة للصف الثاني */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    max-width: 1000px;
    margin: 0 auto 3rem;
    padding: 0 20px;
}
.lesson-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(0,0,0,0.05);
    border: 3px solid transparent;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.lesson-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
    box-shadow: 0 15px 25px rgba(74, 105, 189, 0.2);
}
.lesson-number {
    position: absolute; top: -15px; right: 20px;
    background: var(--primary); color: white;
    padding: 5px 15px; border-radius: 0 0 15px 15px;
    font-weight: bold; font-size: 1.2rem;
}
.lesson-icon { font-size: 4rem; margin: 10px 0; display: block; }
.lesson-name { font-size: 1.5rem; font-weight: bold; color: var(--text); }

/* الدرس الداخلي */
#lesson-view { max-width: 1000px; margin: 2rem auto; background: rgba(255,255,255,0.95); padding: 2rem; border-radius: 25px; box-shadow: var(--shadow); }
.back-btn { background: #7f8fa6; color: white; border: none; padding: 10px 20px; border-radius: 12px; font-size: 1.1rem; cursor: pointer; font-family: inherit; margin-bottom: 20px; font-weight: bold; transition: 0.3s;}
.back-btn:hover { background: #2f3640; }
.lesson-title { text-align: center; font-size: 2.8rem; color: var(--primary); margin-top: 0; border-bottom: 3px dashed #dcdde1; padding-bottom: 15px; }

/* التبويبات */
.lesson-tabs { display: flex; justify-content: center; gap: 15px; margin-bottom: 30px; flex-wrap: wrap; }
.tab-btn { background: #f1f2f6; border: 2px solid transparent; padding: 12px 25px; border-radius: 15px; font-size: 1.2rem; font-weight: bold; cursor: pointer; color: #57606f; transition: all 0.3s; font-family: inherit; display: flex; align-items: center; gap: 8px;}
.tab-btn.active, .tab-btn:hover { background: var(--secondary); color: white; border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(96, 163, 188, 0.4); }

.tab-content { display: none; text-align: center; padding: 2rem; background: #fdfdfd; border-radius: 20px; min-height: 350px; border: 1px solid #eee; }
.tab-content.active-tab { display: block; animation: fadeIn 0.4s; }
.instruction-text { font-size: 1.5rem; color: var(--primary); margin-bottom: 25px; display: inline-block; padding-bottom: 5px; border-bottom: 2px solid var(--accent);}

/* التبويب 1: قراءة الدرس */
.reading-box {
    text-align: right; line-height: 2.2; font-size: 1.8rem; padding: 20px;
    background: #fff; border-radius: 15px; border-right: 6px solid var(--primary);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}
.reading-sentence {
    display: inline-block; padding: 5px 10px; margin: 5px; border-radius: 8px; cursor: pointer; transition: 0.2s;
}
.reading-sentence:hover { background: #ffeaa7; color: var(--primary); transform: scale(1.02); }
.reading-sentence.playing { background: var(--accent); color: #000; }

/* التبويب 2: المعاني */
.vocab-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.vocab-card {
    background: white; border: 3px solid var(--secondary); border-radius: 15px; width: 220px; min-height: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
    transition: 0.4s transform style; transform-style: preserve-3d; position: relative;
    box-shadow: 0 5px 10px rgba(0,0,0,0.05); padding: 15px; text-align: center;
}
.vocab-card:hover { transform: translateY(-5px); border-color: var(--primary); box-shadow: 0 10px 20px rgba(0,0,0,0.1);}
.vocab-word { font-size: 2rem; font-weight: bold; color: var(--primary); }
.vocab-meaning { font-size: 1.3rem; color: var(--success); margin-top: 10px; display: none; font-weight: bold; animation: popIn 0.3s; }
.vocab-card.flipped .vocab-word { color: #888; font-size: 1.2rem; margin-bottom: 5px;}
.vocab-card.flipped .vocab-meaning { display: block; }
.vocab-card.flipped { background: #f1f8e9; border-color: var(--success); }

/* التبويب 3: الترتيب */
.order-drop-zone {
    display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; margin-bottom: 40px;
    padding: 20px; min-height: 80px; align-items: center; border: 3px dashed #bdc3c7; border-radius: 15px; background: #fafafa;
}
.order-words-zone { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.word-pill {
    background: var(--primary); color: white; padding: 10px 20px; border-radius: 30px; font-size: 1.6rem;
    font-weight: bold; cursor: pointer; box-shadow: 0 4px 0 #2c3e50; transition: 0.2s; user-select: none;
}
.word-pill:active { transform: translateY(4px); box-shadow: none; }
.word-slot {
    min-width: 80px; height: 50px; border-bottom: 3px solid var(--text); padding: 5px;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: bold; color: var(--success);
}
.order-result-msg { font-size: 2rem; font-weight: bold; margin-top: 20px; color: var(--success); animation: popIn 0.5s; }

/* التبويب 4: الأسئلة */
.quiz-box { background: white; padding: 30px; border-radius: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.quiz-q { font-size: 2rem; color: var(--primary); margin-bottom: 25px; }
.quiz-options { display: flex; flex-direction: column; gap: 15px; align-items: center; }
.quiz-opt {
    background: #f1f2f6; border: 2px solid #dcdde1; width: 80%; padding: 15px; border-radius: 12px;
    font-size: 1.5rem; cursor: pointer; transition: 0.3s; font-family: inherit; text-align: right;
}
.quiz-opt:hover { background: #eccc68; border-color: #ffa502; transform: scale(1.02); }
.quiz-opt.correct { background: var(--success); color: white; border-color: #2ed573; animation: bouncy 0.4s; }
.quiz-opt.wrong { background: #ff4757; color: white; border-color: #ff6b81; animation: wrong-shake 0.4s; }

@keyframes fadeIn { from{ opacity:0; } to{ opacity:1; } }
@keyframes wrong-shake { 0%,100%{ transform: translateX(0); } 25%{ transform: translateX(-10px); } 75%{ transform: translateX(10px); } }

/* الموبايل */
@media screen and (max-width: 768px) {
    .app-header h1 { font-size: 2.2rem; }
    .lesson-title { font-size: 2rem; }
    .tab-btn { flex: 1 1 45%; justify-content: center; font-size: 1rem; }
    .reading-box { font-size: 1.4rem; line-height: 2; padding: 15px; }
    .word-pill { font-size: 1.2rem; padding: 8px 15px; }
    .quiz-opt { width: 100%; font-size: 1.2rem; }
}
