/* =====================
   الخطوط والمتغيرات
   ===================== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  /* لوحة ألوان مستوحاة من التطبيقات التعليمية المظلمة (Dark Mode) */
  --bg: #0f172a;        /* لون الخلفية الرئيسي */
  --card: #1e293b;      /* لون البطاقات */
  --card-hover: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: #334155;
  
  --accent: #3b82f6;    /* الأزرق (الأساسي) */
  --accent-hover: #2563eb;
  --success: #22c55e;   /* الأخضر (للإجابات الصحيحة) */
  --bad: #ef4444;       /* الأحمر (للأخطاء والتسجيل) */
  --warn: #f59e0b;      /* البرتقالي (للتلميحات) */
  
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0; 
  font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* =====================
   الحركات (Animations)
   ===================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

@keyframes pulseRecord {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.recording-active {
  background-color: var(--bad) !important;
  color: white !important;
  border-color: var(--bad) !important;
  animation: pulseRecord 1.5s infinite;
}

/* =====================
   الهيدر والإحصائيات
   ===================== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(15, 23, 42, 0.9); 
  backdrop-filter: blur(10px); z-index: 100;
}

.brand { display: flex; align-items: center; gap: 12px; }
.app-logo { height: 32px; width: auto; border-radius: 6px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; color: var(--accent); }

.lang-switch select {
  padding: 6px 12px; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--card); color: var(--text); outline: none; cursor: pointer;
  font-family: inherit; font-weight: 600;
}

.stats { display: flex; gap: 12px; }
.stat-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--line);
  font-weight: 700;
}
.xp-icon { color: var(--warn); }
.streak-icon { color: var(--bad); }

/* =====================
   التخطيط الرئيسي (Layout)
   ===================== */
.container {
  display: grid; grid-template-columns: 320px 1fr; gap: 24px;
  padding: 24px; max-width: 1200px; margin: 0 auto;
}

.sidebar {
  border: 1px solid var(--line); border-radius: var(--radius-lg); 
  padding: 16px; background: var(--card);
  height: fit-content;
}

/* =====================
   قائمة الدروس
   ===================== */
.lesson-list { list-style: none; padding: 0; margin: 12px 0 0 0; display: flex; flex-direction: column; gap: 10px; }
.lesson-card-btn {
  width: 100%; padding: 14px; border-radius: var(--radius-md);
  border: 2px solid var(--line); background: rgba(15, 23, 42, 0.5);
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; text-align: inherit; transition: all 0.2s;
}
.lesson-card-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--card-hover); }
.lesson-card-btn.active { border-color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.lesson-card-btn.locked-btn { cursor: not-allowed; opacity: 0.6; border-style: dashed; background: transparent; }

.lesson-list-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.smalltag { font-size: 12px; color: var(--muted); }
.lock-icon { color: var(--warn); font-size: 14px; }
.open-icon { color: var(--success); font-size: 14px; }

/* =====================
   منطقة المحتوى والأسئلة
   ===================== */
.card {
  border: 1px solid var(--line); border-radius: var(--radius-lg); 
  padding: 32px; background: var(--card);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-10 { margin-top: 16px; }

/* شريط التقدم */
.lesson-progress-container {
  height: 8px; background: var(--line); border-radius: 99px;
  margin: 16px 0 24px 0; overflow: hidden;
}
.lesson-progress-fill {
  height: 100%; background: var(--accent);
  transition: width 0.4s ease; border-radius: 99px;
}

/* الأسئلة والخيارات */
.question-prompt h3 { margin: 0 0 16px 0; font-size: 22px; font-weight: 700; }
.transliteration { margin-bottom: 16px; font-style: italic; }

.choices { display: grid; grid-template-columns: 1fr; gap: 12px; }
.choice {
  padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--radius-md);
  cursor: pointer; background: rgba(15, 23, 42, 0.5);
  font-size: 16px; font-weight: 600; text-align: center;
  transition: all 0.2s;
}
.choice:hover { background: var(--card-hover); border-color: var(--muted); }
.choice.selected { border-color: var(--accent); background: rgba(59, 130, 246, 0.1); color: var(--accent); }

/* =====================
   ترتيب الكلمات (Word Order)
   ===================== */
.word-order-area { margin-bottom: 24px; }
.order-selected-line {
  min-height: 60px; border-bottom: 2px dashed var(--line);
  display: flex; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; align-items: flex-end;
}
.tokens-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
.hidden-token { opacity: 0.2; pointer-events: none; border-style: dashed; }
.selected-chip { margin: 0; border-color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.placeholder-dash { color: var(--line); font-size: 24px; font-weight: bold; }

/* =====================
   الإدخال والتسجيل
   ===================== */
.text-input {
  width: 100%; padding: 16px; border-radius: var(--radius-md);
  border: 2px solid var(--line); background: rgba(15, 23, 42, 0.5);
  color: var(--text); font-size: 16px; font-family: inherit; transition: all 0.2s;
}
.text-input:focus { border-color: var(--accent); outline: none; }

.phrase-box {
  padding: 24px; border: 2px solid var(--line); border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.5); font-size: 28px; text-align: center; color: var(--accent);
}

.rec-row { display: flex; justify-content: center; gap: 12px; }
.transcript-box { padding: 12px; border-radius: var(--radius-md); border: 1px dashed var(--line); text-align: center; }

/* =====================
   الأزرار والتغذية الراجعة
   ===================== */
.actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.btn {
  padding: 12px 24px; border-radius: var(--radius-md); border: none;
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
}
.btn.primary { background: var(--accent); color: #fff; flex: 1; }
.btn.primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn.secondary { background: var(--line); color: var(--text); }
.btn.secondary:hover { background: var(--card-hover); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.feedback {
  margin-top: 24px; padding: 16px; border-radius: var(--radius-md);
  font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px;
}
.feedback.good { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.feedback.bad { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }

/* =====================
   التجاوب مع الشاشات (Responsive)
   ===================== */
@media (max-width: 900px) {
  .container { grid-template-columns: 1fr; padding: 16px; }
  .card { padding: 20px; }
  .phrase-box { font-size: 22px; }
  .topbar { padding: 12px 16px; }
}
/* تنسيقات النافذة المنبثقة (Modal) */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(11, 18, 32, 0.85); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px;
  width: 90%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.modal-header { text-align: center; margin-bottom: 24px; }
.modal-icon { font-size: 48px; color: var(--accent); margin-bottom: 16px; }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal-form .btn { width: 100%; }