/* ═══════════════════════════════════════════════════════════════
   BEM Platform Pro — Frontend Design System v2
   Arabic Educational Platform — Algeria 4th Year Middle School
   Font: Tajawal (Google Fonts)
   ═══════════════════════════════════════════════════════════════ */

/* Font loaded globally via theme — no @import needed */

/* ─── CSS Variables ──────────────────────────────────────────── */
:root {
  --bem-primary:      #8b5cf6;
  --bem-primary-dark: #7c3aed;
  --bem-primary-light:#f3f0ff;
  --bem-gold:         #f59e0b;
  --bem-gold-dark:    #d97706;
  --bem-gold-light:   #fef3c7;
  --bem-success:      #34d399;
  --bem-success-light:#ecfdf5;
  --bem-danger:       #f87171;
  --bem-danger-light: #fef2f2;
  --bem-bg:           #f8f7ff;
  --bem-surface:      #ffffff;
  --bem-border:       #ebe5f6;
  --bem-text:         #2d2b3d;
  --bem-text-muted:   #7c7a8a;
  --bem-text-light:   #a5a3b3;
  --bem-radius:       18px;
  --bem-radius-sm:    12px;
  --bem-shadow:       0 2px 16px rgba(139,92,246,.06);
  --bem-shadow-lg:    0 8px 40px rgba(139,92,246,.1);
  --bem-font:         'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Global font for all BEM elements ───────────────────────── */
.bem-auth, .bem-dashboard, #bem-platform-root,
.bem-gate-wrap, .bem-gate-card {
  font-family: var(--bem-font);
  direction: rtl;
  color: var(--bem-text);
}

/* ═══════════════════════════════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ─── Buttons ─────────────────────────────────────────────────── */
.bem-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: var(--bem-radius-sm); border: none; cursor: pointer;
  font-family: var(--bem-font); font-size: 15px; font-weight: 700;
  text-decoration: none; transition: all .25s ease;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff; letter-spacing: .3px; min-height: 48px;
}
.bem-btn:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(139,92,246,.3); color: #fff; }
.bem-btn:active { transform: translateY(0); }
.bem-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.bem-btn--full    { width: 100%; }
.bem-btn--outline {
  background: transparent; border: 2px solid var(--bem-primary);
  color: var(--bem-primary);
}
.bem-btn--outline:hover { background: var(--bem-primary); color: #fff; }
.bem-btn--ghost   { background: var(--bem-bg); color: var(--bem-text-muted); border: 1.5px solid var(--bem-border); }
.bem-btn--ghost:hover { background: var(--bem-border); box-shadow: none; }
.bem-btn--danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.bem-btn--danger:hover { box-shadow: 0 6px 20px rgba(239,68,68,.35); }
.bem-btn--gold    { background: linear-gradient(135deg, var(--bem-gold), var(--bem-gold-dark)); }
.bem-btn--gold:hover { box-shadow: 0 6px 20px rgba(245,158,11,.35); }

/* ─── Messages ────────────────────────────────────────────────── */
.bem-msg {
  padding: 10px 14px; border-radius: var(--bem-radius-sm);
  font-size: 14px; font-weight: 500; min-height: 0;
}
.bem-msg--error   { background: var(--bem-danger-light); color: #dc2626; border-right: 3px solid #f87171; border-radius: var(--bem-radius-sm); }
.bem-msg--success { background: var(--bem-success-light); color: #047857; border-right: 3px solid #34d399; border-radius: var(--bem-radius-sm); }

/* ─── Badges ──────────────────────────────────────────────────── */
.bem-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.bem-badge--active   { background: var(--bem-success-light); color: #065f46; }
.bem-badge--inactive { background: #f1f5f9; color: var(--bem-text-muted); }
.bem-badge--expired  { background: var(--bem-danger-light); color: #c53030; }
.bem-badge--lg { font-size: 14px; padding: 7px 20px; margin-bottom: 14px; }

/* ─── Progress Bars ───────────────────────────────────────────── */
.bem-progress { height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.bem-progress__bar { height: 100%; border-radius: 5px; transition: width .5s ease; }
.bem-progress__bar--green  { background: linear-gradient(90deg, #10b981, #34d399); }
.bem-progress__bar--orange { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bem-progress__bar--red    { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ─── Google Button ───────────────────────────────────────────── */
.bem-google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 16px;
  background: #fff; border: 1.5px solid var(--bem-border); border-radius: var(--bem-radius-sm);
  font-family: var(--bem-font); font-size: 15px; font-weight: 600; color: var(--bem-text);
  text-decoration: none; cursor: pointer; transition: all .25s; margin-bottom: 16px;
  box-shadow: 0 1px 6px rgba(139,92,246,.05);
}
.bem-google-btn:hover { box-shadow: 0 4px 16px rgba(139,92,246,.1); background: var(--bem-primary-light); text-decoration: none; color: var(--bem-text); border-color: var(--bem-primary); }
.bem-google-divider {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; color: var(--bem-text-light); font-size: 13px; font-weight: 500;
}
.bem-google-divider::before, .bem-google-divider::after { content:''; flex:1; height:1px; background: var(--bem-border); }

/* ─── Gate (blocked content) ──────────────────────────────────── */
.bem-gate-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 70vh; padding: 40px 16px; background: var(--bem-bg);
}
.bem-gate-card {
  background: var(--bem-surface); border-radius: 24px; padding: 52px 40px;
  text-align: center; max-width: 500px; width: 100%;
  box-shadow: var(--bem-shadow-lg); border: 1px solid var(--bem-border);
}
.bem-gate-card--sub { border-top: 4px solid var(--bem-gold); }
.bem-gate-icon   { font-size: 68px; margin-bottom: 20px; }
.bem-gate-title  { font-size: 24px; font-weight: 800; color: var(--bem-text); margin: 0 0 12px; }
.bem-gate-text   { font-size: 16px; color: var(--bem-text-muted); line-height: 1.8; margin: 0 0 32px; }
.bem-gate-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 36px; background: linear-gradient(135deg, var(--bem-primary), var(--bem-primary-dark));
  color: #fff; border-radius: var(--bem-radius-sm); font-family: var(--bem-font);
  font-size: 16px; font-weight: 700; text-decoration: none; transition: all .2s;
  box-shadow: 0 4px 16px rgba(124,58,237,.3); min-height: 52px;
}
.bem-gate-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,.4); color: #fff; }
.bem-gate-btn--outline {
  background: transparent; border: 2px solid var(--bem-primary); color: var(--bem-primary);
  box-shadow: none; margin-top: 12px;
}
.bem-gate-btn--outline:hover { background: var(--bem-primary); color: #fff; }
.bem-notice--info {
  padding: 14px 18px; background: var(--bem-primary-light);
  border-right: 4px solid var(--bem-primary); border-radius: var(--bem-radius-sm);
  font-size: 14px; color: #6d28d9;
}

/* ═══════════════════════════════════════════════════════════════
   AUTH FORM — تسجيل الدخول وإنشاء الحساب
   ═══════════════════════════════════════════════════════════════ */

/* Auth page wrapper — full-screen centered background */
.bem-auth-page {
  min-height: 100vh;
  background: var(--bem-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

/* Auth card container */
.bem-auth {
  max-width: 440px; width: 100%;
  background: var(--bem-surface);
  border-radius: var(--bem-radius);
  border: 1px solid var(--bem-border);
  padding: 36px 32px;
  box-shadow: var(--bem-shadow-lg);
  direction: rtl;
}

@media (max-width: 480px) {
  .bem-auth-page { padding: 20px 12px; }
  .bem-auth { padding: 24px 18px; }
}
.bem-auth__brand {
  text-align: center; margin-bottom: 28px;
}
.bem-auth__brand-logo {
  width: 72px; height: 72px; background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  border-radius: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 12px; box-shadow: 0 8px 28px rgba(139,92,246,.25);
}
.bem-auth__brand-name { font-size: 22px; font-weight: 800; color: var(--bem-text); margin: 0 0 4px; }
.bem-auth__brand-sub  { font-size: 13px; color: var(--bem-text-muted); margin: 0; }

.bem-auth__tabs {
  display: flex; gap: 0; margin-bottom: 0;
  background: var(--bem-bg); border-radius: 14px; padding: 5px;
}
.bem-auth__tab {
  flex: 1; padding: 10px; border: none; background: transparent; cursor: pointer;
  font-family: var(--bem-font); font-size: 15px; font-weight: 600; color: var(--bem-text-muted);
  border-radius: 8px; transition: all .2s;
}
.bem-auth__tab--active {
  background: var(--bem-surface); color: var(--bem-primary);
  box-shadow: 0 2px 10px rgba(139,92,246,.1);
}
.bem-auth__panel { display: none; padding: 24px 0 0; }
.bem-auth__panel--active { display: block; animation: bemFadeIn .25s ease; }

/* Form Fields */
.bem-form-group { margin-bottom: 18px; }
.bem-form-group label {
  display: block; font-size: 14px; font-weight: 700; margin-bottom: 7px;
  color: var(--bem-text);
}
.bem-form-group input {
  width: 100%; padding: 13px 16px; border: 2px solid var(--bem-border);
  border-radius: var(--bem-radius-sm); font-family: var(--bem-font); font-size: 15px;
  color: var(--bem-text); background: var(--bem-surface); transition: all .2s;
  -webkit-appearance: none;
}
.bem-form-group input:focus {
  outline: none; border-color: var(--bem-primary);
  box-shadow: 0 0 0 4px rgba(124,58,237,.12);
}
.bem-form-group input::placeholder { color: var(--bem-text-light); }

.bem-pass-wrap { position: relative; }
.bem-pass-wrap input { padding-left: 46px; }
.bem-pass-toggle {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px;
  color: var(--bem-text-light); transition: color .2s; line-height: 1;
}
.bem-pass-toggle:hover { color: var(--bem-primary); }

/* ─── Auth Form — Professional Enhancements ──────────────────── */

/* Auth card needs relative for loading overlay */
.bem-auth { position: relative; }

/* Loading overlay on form submit */
.bem-auth--loading::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.65);
  border-radius: var(--bem-radius);
  z-index: 10;
  backdrop-filter: blur(2px);
  animation: bemFadeIn .2s ease;
}
.bem-dark .bem-auth--loading::after {
  background: rgba(15,10,26,.65);
}

/* Button spinner */
.bem-btn-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bemSpin .7s linear infinite;
  vertical-align: middle;
}
.bem-btn__loader {
  display: inline-flex; align-items: center; gap: 8px;
}

/* Field validation states */
.bem-form-group input.bem-valid {
  border-color: var(--bem-success);
}
.bem-form-group input.bem-valid:focus {
  box-shadow: 0 0 0 4px rgba(52,211,153,.15);
}
.bem-form-group input.bem-invalid {
  border-color: var(--bem-danger);
}
.bem-form-group input.bem-invalid:focus {
  box-shadow: 0 0 0 4px rgba(248,113,113,.15);
}

/* Inline field error message */
.bem-field-error {
  font-size: 12px; font-weight: 600;
  color: #dc2626; margin-top: 5px;
  min-height: 0; overflow: hidden;
  max-height: 0; opacity: 0;
  transition: max-height .25s ease, opacity .25s ease, margin .25s ease;
}
.bem-field-error.visible {
  max-height: 30px; opacity: 1; margin-top: 5px;
}
.bem-dark .bem-field-error { color: #fca5a5; }

/* Password strength meter */
.bem-strength {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
}
.bem-strength__meter {
  flex: 1; height: 5px;
  background: var(--bem-border);
  border-radius: 3px; overflow: hidden;
}
.bem-strength__bar {
  height: 100%; width: 0;
  border-radius: 3px;
  transition: width .35s ease, background .35s ease;
}
.bem-strength__bar--weak   { width: 33%; background: #ef4444; }
.bem-strength__bar--medium { width: 66%; background: #f59e0b; }
.bem-strength__bar--strong { width: 100%; background: #10b981; }

.bem-strength__label {
  font-size: 11px; font-weight: 700;
  min-width: 40px; text-align: center;
  transition: color .3s;
}
.bem-strength__label--weak   { color: #ef4444; }
.bem-strength__label--medium { color: #f59e0b; }
.bem-strength__label--strong { color: #10b981; }

/* Shake animation for invalid submit */
@keyframes bemShake {
  0%, 100% { transform: translateX(0); }
  15%, 55% { transform: translateX(-5px); }
  35%, 75% { transform: translateX(5px); }
}
.bem-shake { animation: bemShake .4s ease; }

/* Auth switch links (bottom of each tab) */
.bem-auth__switch {
  text-align: center; margin-top: 20px;
  font-size: 13px; color: var(--bem-text-muted);
}
.bem-auth__switch-link {
  background: none; border: none;
  color: var(--bem-primary); font-weight: 700;
  cursor: pointer; font-size: 13px;
  font-family: var(--bem-font);
  transition: color .2s;
}
.bem-auth__switch-link:hover { color: var(--bem-primary-dark); text-decoration: underline; }

/* Auth footer (contact info) */
.bem-auth__footer {
  text-align: center; margin-top: 28px;
  padding-top: 20px; border-top: 1px solid var(--bem-border);
}
.bem-auth__footer-label  { font-size: 12px; color: var(--bem-text-light); margin: 0; }
.bem-auth__footer-phone  {
  font-size: 15px; font-weight: 800; color: var(--bem-primary);
  text-decoration: none; display: inline-flex; align-items: center;
  gap: 6px; margin-top: 6px; transition: color .2s;
}
.bem-auth__footer-phone:hover { color: var(--bem-primary-dark); }
.bem-auth__footer-region { font-size: 11px; color: var(--bem-text-light); margin: 8px 0 0; }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD — لوحة تحكم الطالب
   ═══════════════════════════════════════════════════════════════ */
.bem-dashboard {
  max-width: 900px; margin: 0 auto; padding: 0 16px; direction: rtl;
}

/* Header */
.bem-dash__header {
  display: flex; align-items: center; gap: 20px; padding: 28px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
  border-radius: 22px; color: #fff; margin-bottom: 24px; flex-wrap: wrap;
  box-shadow: 0 8px 32px rgba(139,92,246,.25); position: relative; overflow: hidden;
}
.bem-dash__header::before {
  content: ''; position: absolute; top: -40px; left: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.06); pointer-events: none;
}
.bem-dash__avatar {
  width: 68px; height: 68px; background: rgba(255,255,255,.2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; flex-shrink: 0;
  border: 3px solid rgba(255,255,255,.35); position: relative; z-index: 1;
}
.bem-dash__info { flex: 1; position: relative; z-index: 1; }
.bem-dash__name  { margin: 0 0 5px; font-size: 20px; font-weight: 800; }
.bem-dash__email,
.bem-dash__phone { margin: 0; font-size: 13px; opacity: .85; }
.bem-dash__phone { margin-top: 2px; }
.bem-dash__badges { position: relative; z-index: 1; }

/* Stats Row — side by side cards */
.bem-dash__stats-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px;
}
.bem-dash__grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px;
}

/* Cards */
.bem-card {
  background: var(--bem-surface); border: 1px solid var(--bem-border);
  border-radius: var(--bem-radius); padding: 22px;
  box-shadow: var(--bem-shadow); transition: box-shadow .2s;
}
.bem-card:hover { box-shadow: var(--bem-shadow-lg); }
.bem-card--compact { padding: 20px; }
.bem-card__title {
  margin: 0 0 18px; font-size: 15px; font-weight: 700; color: var(--bem-text);
  border-bottom: 2px solid var(--bem-bg); padding-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.bem-card__icon-title {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.bem-card__icon { font-size: 20px; line-height: 1; }
.bem-card__title-inline {
  margin: 0; font-size: 15px; font-weight: 700; color: var(--bem-text);
}
.bem-card__note  { margin: 8px 0 0; font-size: 13px; color: var(--bem-text-light); }

/* AI Stats */
.bem-ai-stat { display: flex; align-items: baseline; gap: 6px; margin-bottom: 14px; }
.bem-ai-stat__num   { font-size: 44px; font-weight: 900; color: var(--bem-primary); line-height: 1; }
.bem-ai-stat__sep   { font-size: 22px; color: var(--bem-text-light); }
.bem-ai-stat__total { font-size: 20px; color: var(--bem-text-light); }

/* Subscription */
.bem-sub-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--bem-bg); font-size: 14px;
}
.bem-sub-row:last-of-type { border-bottom: none; }
.bem-sub-row__label { color: var(--bem-text-muted); }
.bem-days-left {
  margin-top: 12px; font-size: 14px; font-weight: 600; color: #059669;
  text-align: center; background: var(--bem-success-light); padding: 8px 12px;
  border-radius: var(--bem-radius-sm);
}
.bem-days-left--urgent { color: #dc2626; background: var(--bem-danger-light); }

/* Readiness */
.bem-card--readiness { margin-top: 0; }
.bem-readiness-overall { margin-bottom: 22px; }
.bem-readiness-overall__label { font-size: 14px; font-weight: 700; color: var(--bem-text); margin-bottom: 10px; }
.bem-readiness-overall__row { display: flex; align-items: center; gap: 14px; }
.bem-readiness-overall__pct { font-size: 15px; font-weight: 800; white-space: nowrap; }
.bem-readiness-overall__pct--red    { color: #dc2626; }
.bem-readiness-overall__pct--orange { color: #d97706; }
.bem-readiness-overall__pct--blue   { color: #2563eb; }
.bem-readiness-overall__pct--green  { color: #059669; }

.bem-readiness-bar-lg {
  flex: 1; height: 14px; background: var(--bem-bg); border-radius: 7px; overflow: hidden;
}
.bem-readiness-bar-lg__fill { height: 100%; border-radius: 7px; transition: width .5s ease; }
.bem-readiness-bar-lg--red    { background: linear-gradient(90deg, #ef4444, #dc2626); }
.bem-readiness-bar-lg--orange { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bem-readiness-bar-lg--blue   { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.bem-readiness-bar-lg--green  { background: linear-gradient(90deg, #10b981, #059669); }

.bem-readiness-subjects { display: grid; gap: 12px; }
.bem-readiness-subject {
  display: flex; align-items: center; gap: 14px; padding: 10px 0;
  border-bottom: 1px solid var(--bem-bg);
}
.bem-readiness-subject:last-child { border-bottom: none; }
.bem-readiness-subject__name {
  flex: 0 0 110px; font-size: 14px; font-weight: 700; color: var(--bem-text);
}
.bem-readiness-subject__bar { flex: 1; display: flex; align-items: center; gap: 10px; }
.bem-readiness-bar-sm {
  flex: 1; height: 10px; background: var(--bem-bg); border-radius: 5px; overflow: hidden;
}
.bem-readiness-bar-sm__fill { height: 100%; border-radius: 5px; transition: width .5s ease; }
.bem-readiness-bar-sm--red    { background: linear-gradient(90deg, #ef4444, #dc2626); }
.bem-readiness-bar-sm--orange { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bem-readiness-bar-sm--blue   { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.bem-readiness-bar-sm--green  { background: linear-gradient(90deg, #10b981, #059669); }
.bem-readiness-subject__pct { font-size: 13px; font-weight: 800; white-space: nowrap; }
.bem-readiness-subject__pct--red    { color: #dc2626; }
.bem-readiness-subject__pct--orange { color: #d97706; }
.bem-readiness-subject__pct--blue   { color: #2563eb; }
.bem-readiness-subject__pct--green  { color: #059669; }
.bem-readiness-subject__new  { font-size: 12px; color: var(--bem-text-light); }
.bem-readiness-subject__stat { font-size: 12px; color: var(--bem-text-light); white-space: nowrap; }

/* Actions */
.bem-dash__actions {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.bem-dash__actions-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.bem-btn--primary-lg {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px; font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--bem-primary), var(--bem-primary-dark));
  color: #fff; border: none; border-radius: var(--bem-radius-sm); cursor: pointer;
  text-decoration: none; transition: all .2s;
  box-shadow: 0 4px 16px rgba(139,92,246,.2);
}
.bem-btn--primary-lg:hover {
  transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,92,246,.3);
}
.bem-btn--outline-sm {
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--bem-text-muted); border: 1px solid var(--bem-border);
  border-radius: var(--bem-radius-sm); cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.bem-btn--outline-sm:hover {
  border-color: var(--bem-primary); color: var(--bem-primary); background: var(--bem-primary-light);
}
.bem-form-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Footer */
.bem-dash__footer {
  padding: 20px 0; text-align: center; margin-top: 10px;
}
.bem-btn--logout {
  padding: 10px 28px; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--bem-text-light); border: 1px solid var(--bem-border);
  border-radius: var(--bem-radius-sm); cursor: pointer; transition: all .2s;
  font-family: var(--bem-font);
}
.bem-btn--logout:hover {
  color: var(--bem-danger); border-color: var(--bem-danger); background: var(--bem-danger-light);
}

/* ═══════════════════════════════════════════════════════════════
   CONTENT PLATFORM — المنصة التعليمية
   ═══════════════════════════════════════════════════════════════ */
#bem-platform-root {
  display: flex; flex-direction: column; min-height: 100vh;
  direction: rtl; font-family: var(--bem-font); background: var(--bem-bg);
}

/* Top Bar */
.bem-topbar {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
  color: #fff; padding: 0 28px;
  box-shadow: 0 4px 20px rgba(139,92,246,.2);
  display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; position: sticky; top: 0; z-index: 100;
}
.bem-topbar h1 {
  font-size: 18px; font-weight: 800; letter-spacing: .2px; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.bem-topbar h1::before {
  content: '📚'; font-size: 22px;
}
.bem-topbar-right {
  display: flex; align-items: center; gap: 12px; font-size: 13px; opacity: .9;
}

/* Layout */
.bem-layout {
  display: flex; flex: 1; max-width: 1440px; margin: 0 auto;
  width: 100%; gap: 20px; padding: 20px;
}

/* Sidebar */
.bem-sidebar {
  width: 290px; flex-shrink: 0; background: var(--bem-surface);
  border-radius: var(--bem-radius); box-shadow: var(--bem-shadow);
  height: fit-content; position: sticky; top: 84px; overflow: hidden;
  border: 1px solid var(--bem-border);
}
.bem-sidebar-title {
  padding: 16px 20px; background: linear-gradient(135deg, #f8f7ff, #f3f0ff);
  font-size: 13px; font-weight: 700; color: var(--bem-text-muted);
  border-bottom: 1px solid var(--bem-border); letter-spacing: .5px; text-transform: uppercase;
}
.bem-sidebar-item {
  padding: 15px 20px; border-bottom: 1px solid #f8fafc;
  cursor: pointer; transition: all .18s; position: relative;
}
.bem-sidebar-item:hover  { background: var(--bem-primary-light); }
.bem-sidebar-item.active {
  background: var(--bem-primary-light);
  border-right: 4px solid var(--bem-primary);
}
.bem-sidebar-item-title  { font-size: 14px; color: var(--bem-text); font-weight: 600; margin-bottom: 3px; }
.bem-sidebar-item.active .bem-sidebar-item-title { color: var(--bem-primary); }
.bem-sidebar-item-meta   { font-size: 11px; color: var(--bem-text-light); }

/* Content area */
.bem-content { flex: 1; min-width: 0; }

/* Loading */
.bem-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 400px; color: var(--bem-text-muted);
  text-align: center; padding: 60px 20px; gap: 16px;
}
.bem-spinner {
  width: 52px; height: 52px; border: 4px solid var(--bem-border);
  border-top-color: var(--bem-primary); border-radius: 50%;
  animation: bemSpin .7s linear infinite;
}

/* Breadcrumb */
.bem-breadcrumb {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  background: var(--bem-surface); border-radius: var(--bem-radius-sm);
  margin-bottom: 16px; box-shadow: var(--bem-shadow); font-size: 13px;
  border: 1px solid var(--bem-border); flex-wrap: wrap;
}
.bem-breadcrumb button {
  background: none; border: none; color: var(--bem-primary); cursor: pointer;
  font-family: var(--bem-font); font-size: 13px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px; transition: background .2s;
}
.bem-breadcrumb button:hover { background: var(--bem-primary-light); }
.bem-breadcrumb span { color: var(--bem-text-light); }

/* Grid */
.bem-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px;
}
.bem-grid-item {
  background: var(--bem-surface); padding: 26px; border-radius: var(--bem-radius);
  cursor: pointer; transition: all .3s ease; box-shadow: var(--bem-shadow);
  border: 1.5px solid var(--bem-border); position: relative; overflow: hidden;
}
.bem-grid-item::before {
  content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--bem-primary-light) 0%, transparent 60%);
  opacity: 0; transition: opacity .25s;
}
.bem-grid-item:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(139,92,246,.12); border-color: rgba(139,92,246,.3); }
.bem-grid-item:hover::before { opacity: 1; }
.bem-grid-item-icon  { font-size: 32px; margin-bottom: 12px; position: relative; }
.bem-grid-item-title { font-size: 15px; color: var(--bem-text); font-weight: 700; margin-bottom: 6px; position: relative; line-height: 1.4; }
.bem-grid-item-meta  { font-size: 12px; color: var(--bem-text-muted); position: relative; }

/* Unit Readiness */
.bem-unit-readiness { margin-top: 10px; position: relative; }

/* Lesson Box */
/* ═══════════════════════════════════════════════════════
   LESSON CONTENT — Clean Textbook Style
   ═══════════════════════════════════════════════════════ */
.bem-lesson-box {
  background: #fff;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
  margin-bottom: 24px;
  border: none;
  overflow: hidden;
}
.bem-lesson-title {
  font-size: 22px;
  color: #fff;
  font-weight: 800;
  margin: 0;
  padding: 18px 28px;
  background: linear-gradient(135deg, #6d28d9, #4c1d95);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.6;
  border-bottom: none;
}
.bem-lesson-title::before { content: '📖'; font-size: 22px; }
.bem-lesson-content {
  line-height: 2.2;
  font-size: 16.5px;
  color: #1e1b2e;
  direction: rtl;
  padding: 28px 32px;
}
.bem-lesson-content p {
  margin: 0 0 16px;
  line-height: 2.1;
}

/* ─── h3: Main sections (I, II, III) ─────────────────── */
.bem-lesson-content h3 {
  font-size: 1.12em !important;
  font-weight: 800 !important;
  color: #4c1d95 !important;
  margin: 30px 0 14px !important;
  padding: 0 0 8px !important;
  background: none !important;
  border: none !important;
  border-bottom: 2px solid #8b5cf6 !important;
  border-radius: 0 !important;
  display: block !important;
}

/* ─── h4: Sub-sections (1, 2, 3) ─────────────────────── */
.bem-lesson-content h4 {
  font-size: 1.02em;
  font-weight: 700;
  color: #6d28d9;
  margin: 20px 0 8px;
  padding: 0;
  background: none;
  border: none;
}

/* ─── Bold & strong ──────────────────────────────────── */
.bem-lesson-content strong {
  color: #5b21b6;
  font-weight: 700;
}

/* ─── Note box (> text) — info ───────────────────────── */
.bem-lesson-content .bem-note {
  background: #eff6ff;
  border-right: 3px solid #3b82f6;
  border-radius: 0 8px 8px 0;
  padding: 10px 16px;
  margin: 14px 0;
  color: #1e40af;
}

/* ─── Key rule (!> text) — important ─────────────────── */
.bem-lesson-content .bem-key {
  background: #fefce8;
  border: 1.5px solid #fbbf24;
  border-right: 4px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  padding: 10px 16px;
  margin: 14px 0;
  color: #92400e;
  font-weight: 600;
}

/* ─── Intro (^> text) — highlight ────────────────────── */
.bem-lesson-content .bem-intro {
  background: #f0fdf4;
  border-right: 3px solid #22c55e;
  border-radius: 0 8px 8px 0;
  padding: 10px 16px;
  margin: 14px 0;
  color: #166534;
}

/* ─── Display math ($$...$$) ─────────────────────────── */
.bem-lesson-content .katex-display {
  background: #f9f8ff;
  border: 1px solid #ede9fe;
  border-radius: 10px;
  padding: 16px 20px;
  margin: 18px 0;
  font-size: 1.12em;
  text-align: center;
}

/* ─── Inline math ($...$) ────────────────────────────── */
.bem-lesson-content .katex:not(.katex-display .katex) {
  color: #6d28d9;
}

/* ─── Quran block ────────────────────────────────────── */
.bem-lesson-content .quran-block {
  font-family: "Scheherazade New", "Traditional Arabic", "Amiri", Georgia, serif !important;
  font-size: 1.28em !important;
  line-height: 3.2 !important;
  text-align: justify !important;
  background: #f8fdf9 !important;
  border: 1px solid #c8e6c9 !important;
  border-right: 4px solid #2e7d32 !important;
  border-radius: 10px !important;
  padding: 20px 24px 16px !important;
  margin: 20px 0 !important;
  direction: rtl !important;
}
.bem-lesson-content .bismillah {
  text-align: center !important;
  font-size: 1.18em !important;
  color: #2e7d32 !important;
  font-weight: 800 !important;
  margin-bottom: 14px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px dashed #c8e6c9 !important;
  display: block;
}
.bem-lesson-content .ayah { color: #1a2e1a; display: inline; }

/* ─── Tables ─────────────────────────────────────────── */
.bem-lesson-content table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 18px 0 !important;
  font-size: 15px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e0f0;
}
.bem-lesson-content th {
  background: #6d28d9 !important;
  color: #fff !important;
  padding: 12px 16px !important;
  text-align: center !important;
  font-weight: 700 !important;
  font-size: 14.5px;
  letter-spacing: .3px;
}
.bem-lesson-content td {
  padding: 10px 16px !important;
  border-bottom: 1px solid #ede9fe !important;
  border-right: none !important;
  border-left: none !important;
  vertical-align: top !important;
  line-height: 1.9 !important;
}
.bem-lesson-content tr:nth-child(even) td { background: #faf8ff; }
.bem-lesson-content tr:hover td { background: #f3f0ff; }

/* ─── Ordered lists ──────────────────────────────────── */
.bem-lesson-content ol {
  padding-right: 0;
  padding-left: 0;
  margin: 12px 0 18px;
  counter-reset: lesson-step;
  list-style: none;
}
.bem-lesson-content ol li {
  counter-increment: lesson-step;
  position: relative;
  margin: 6px 0;
  line-height: 2.1;
  padding: 6px 36px 6px 0;
}
.bem-lesson-content ol li::before {
  content: counter(lesson-step);
  position: absolute;
  right: 0;
  top: 6px;
  min-width: 26px;
  height: 26px;
  background: #6d28d9;
  color: #fff;
  border-radius: 50%;
  font-size: 0.82em;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── Unordered lists ────────────────────────────────── */
.bem-lesson-content ul {
  padding-right: 18px;
  padding-left: 0;
  margin: 12px 0 18px;
  list-style: none;
}
.bem-lesson-content ul li {
  margin: 5px 0;
  line-height: 2.1;
  padding-right: 14px;
  position: relative;
}
.bem-lesson-content ul li::before {
  content: '';
  position: absolute;
  right: 0;
  top: 13px;
  width: 6px;
  height: 6px;
  background: #8b5cf6;
  border-radius: 50%;
}

/* ─── Images inside content ──────────────────────────── */
.bem-lesson-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--bem-radius-sm);
  margin: 14px auto;
  box-shadow: var(--bem-shadow);
  border: 1px solid var(--bem-border);
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .bem-lesson-content { font-size: 15.5px; }
  .bem-lesson-content table { display: block; overflow-x: auto; font-size: 13.5px; }
  .bem-lesson-content .quran-block { font-size: 1.12em !important; line-height: 2.8 !important; padding: 14px 16px 12px !important; }
}

/* Math / LTR */
.bem-exercise-content p,
.bem-solution-content  p { unicode-bidi: plaintext; }
.bem-exercise-figure,
.bem-lesson-figure,
.bem-math-table { direction: ltr; unicode-bidi: embed; display: block; margin: 16px 0; }
.bem-lesson-figure svg,
.bem-exercise-figure svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.bem-lesson-figure table { background: #162032; border-radius: 8px; overflow: hidden; width: 100%; }
.bem-lesson-figure table td,
.bem-lesson-figure table th { color: #e2e8f0; }
.katex, .katex-display { direction: ltr !important; unicode-bidi: embed; }
.bem-jxg {
  display: block; width: 100%; height: 260px;
  background: #f8fafc; border-radius: 10px;
  border: 1px solid var(--bem-border); overflow: hidden; margin: 16px 0;
}
.bem-jxg .JXGtext { font-family: var(--bem-font) !important; }
.bem-jxg .jxgbox { width: 100% !important; height: 100% !important; }

/* Lesson Media */
.bem-lesson-images {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 20px 0; justify-content: flex-start;
}
.bem-lesson-image {
  width: auto; max-width: 320px; max-height: 260px;
  object-fit: contain; border-radius: var(--bem-radius);
  border: 1px solid var(--bem-border);
  box-shadow: var(--bem-shadow);
  cursor: zoom-in; transition: transform .2s;
  background: #fff;
}
.bem-lesson-image:hover { transform: scale(1.04); z-index: 2; box-shadow: var(--bem-shadow-lg); }
/* Lightbox on click */
.bem-lesson-image.zoomed {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(1);
  max-width: 90vw; max-height: 90vh; z-index: 9999;
  border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.7);
  cursor: zoom-out;
}
.bem-lesson-video {
  width: 100%; max-width: 800px; aspect-ratio: 16/9; border-radius: var(--bem-radius);
  margin: 24px 0; box-shadow: var(--bem-shadow-lg); border: none;
}
.bem-lesson-pdf {
  display: inline-flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: linear-gradient(135deg, #e91e63, #f06292);
  color: #fff; text-decoration: none; border-radius: var(--bem-radius-sm);
  margin: 20px 0; font-weight: 700; font-size: 15px; transition: all .2s;
  box-shadow: 0 4px 16px rgba(233,30,99,.3);
}
.bem-lesson-pdf:hover { transform: translateY(-2px); color: #fff; }

/* Exercises */
.bem-exercises-section { margin-top: 28px; }
.bem-section-title {
  background: var(--bem-surface); padding: 16px 22px; border-radius: var(--bem-radius-sm);
  margin-bottom: 16px; box-shadow: var(--bem-shadow); font-size: 17px; font-weight: 800;
  color: var(--bem-text); border-right: 5px solid var(--bem-primary);
  border: 1px solid var(--bem-border); border-right-width: 5px;
  display: flex; align-items: center; gap: 10px;
}
.bem-exercise-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; padding: 6px;
  background: var(--bem-surface); border-radius: var(--bem-radius-sm);
  box-shadow: var(--bem-shadow); flex-wrap: wrap; border: 1px solid var(--bem-border);
}
.bem-tab {
  flex: 1; padding: 11px 18px; background: transparent; border: none;
  border-radius: 8px; font-family: var(--bem-font); font-size: 14px;
  font-weight: 600; color: var(--bem-text-muted); cursor: pointer; transition: all .2s;
  min-width: 100px; min-height: 44px;
}
.bem-tab:hover  { background: var(--bem-bg); color: var(--bem-text); }
.bem-tab.active { background: var(--bem-primary); color: #fff; box-shadow: 0 3px 10px rgba(124,58,237,.3); }

.bem-exercise-card {
  background: var(--bem-surface); padding: 28px; border-radius: var(--bem-radius);
  box-shadow: var(--bem-shadow); margin-bottom: 16px; border: 1px solid var(--bem-border);
  transition: box-shadow .2s;
}
.bem-exercise-card:hover { box-shadow: var(--bem-shadow-lg); }
.bem-exercise-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--bem-bg);
  flex-wrap: wrap; gap: 12px;
}
.bem-exercise-number { display: flex; align-items: center; gap: 14px; }
.bem-exercise-num {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--bem-primary), var(--bem-primary-dark));
  color: #fff; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 17px;
  box-shadow: 0 3px 10px rgba(124,58,237,.3);
}
.bem-exercise-label   { font-size: 17px; color: var(--bem-text); font-weight: 700; }
.bem-difficulty       { display: flex; gap: 3px; }
.bem-star             { color: #f59e0b; font-size: 16px; }
.bem-star.inactive    { color: #e2e8f0; }
.bem-exercise-content { margin-bottom: 26px; line-height: 1.8; font-size: 16px; color: var(--bem-text); }
.bem-exercise-content img { max-width: 100%; height: auto; border-radius: var(--bem-radius-sm); margin: 16px 0; }

.bem-btn-solution {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 300px; margin: 0 auto; padding: 14px 28px;
  background: linear-gradient(135deg, var(--bem-primary), var(--bem-primary-dark));
  color: #fff; border: none; border-radius: var(--bem-radius-sm);
  font-family: var(--bem-font); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all .2s; box-shadow: 0 4px 14px rgba(124,58,237,.3);
  min-height: 52px;
}
.bem-btn-solution:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,.4); }

.bem-solution-box {
  margin-top: 22px; padding: 26px;
  background: linear-gradient(135deg, #f0fdf9, #ecfdf5);
  border-radius: var(--bem-radius-sm); border-right: 4px solid #34d399;
}
.bem-solution-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bem-solution-icon   { font-size: 24px; }
.bem-solution-title  { font-size: 17px; color: #047857; font-weight: 800; }
.bem-solution-content { line-height: 1.8; font-size: 15px; color: #065f46; }

/* Empty / Error */
.bem-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 360px; background: var(--bem-surface);
  border-radius: var(--bem-radius); box-shadow: var(--bem-shadow); gap: 12px;
  border: 1px solid var(--bem-border);
}
.bem-empty-icon { font-size: 72px; opacity: .3; }
.bem-empty-text { font-size: 16px; color: var(--bem-text-muted); font-weight: 500; }

.bem-error {
  background: var(--bem-danger-light); color: #c62828;
  padding: 18px 24px; border-radius: var(--bem-radius-sm);
  text-align: center; font-weight: 600; border-right: 5px solid #ef4444;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR TEST SECTION
   ═══════════════════════════════════════════════════════════════ */
.bem-sidebar-divider { height: 1px; background: var(--bem-border); margin: 8px 16px; }
.bem-sidebar-item--test {
  background: linear-gradient(135deg, rgba(124,58,237,.06), rgba(91,33,182,.06));
  border-right: 3px solid var(--bem-primary);
}
.bem-sidebar-item--test:hover {
  background: linear-gradient(135deg, rgba(124,58,237,.12), rgba(91,33,182,.12));
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .bem-layout { padding: 14px; }
  .bem-sidebar { width: 260px; }
}

@media (max-width: 768px) {
  .bem-topbar { padding: 0 16px; min-height: 58px; }
  .bem-topbar h1 { font-size: 16px; }
  .bem-topbar-right { display: none; }

  .bem-layout { flex-direction: column; gap: 14px; padding: 12px; }
  .bem-sidebar { width: 100%; position: static; border-radius: var(--bem-radius-sm); }

  .bem-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .bem-grid-item { padding: 18px; }

  .bem-lesson-box, .bem-exercise-card { padding: 20px; }
  .bem-exercise-header { flex-direction: column; align-items: flex-start; }

  .bem-dash__header { padding: 20px 18px; gap: 14px; }
  .bem-dash__name   { font-size: 18px; }
  .bem-dash__grid   { grid-template-columns: 1fr; }
  .bem-dash__stats-row { grid-template-columns: 1fr; }
  .bem-dash__actions { flex-direction: column; }
  .bem-dash__actions .bem-btn { width: 100%; justify-content: center; }
  .bem-dash__actions-bar { flex-direction: column; }
  .bem-dash__actions-bar .bem-btn--primary-lg { width: 100%; }
  .bem-dash__actions-bar .bem-btn--outline-sm { width: 100%; text-align: center; }

  .bem-gate-card { padding: 32px 20px; }

  .bem-breadcrumb { font-size: 12px; padding: 10px 14px; }
}

@media (max-width: 480px) {
  .bem-grid { grid-template-columns: 1fr; }
  .bem-lesson-title { font-size: 18px; }
  .bem-auth { padding: 0 4px; }
  .bem-tab { font-size: 13px; padding: 10px 12px; min-width: 80px; }
}

/* ═══════════════════════════════════════════════════════════════
   PWA INSTALL BANNER
   ═══════════════════════════════════════════════════════════════ */
.bem-pwa-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--bem-surface, #fff);
  border-top: 1px solid var(--bem-border, #ebe5f6);
  box-shadow: 0 -4px 24px rgba(0,0,0,.1);
  font-family: var(--bem-font, 'Tajawal', sans-serif);
  direction: rtl;
  animation: bemSlideUp .35s ease;
}
.bem-pwa-banner__content {
  display: flex; align-items: center; gap: 12px; flex: 1;
}
.bem-pwa-banner__icon {
  width: 44px; height: 44px; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(139,92,246,.15);
}
.bem-pwa-banner__text {
  display: flex; flex-direction: column; gap: 2px;
}
.bem-pwa-banner__text strong {
  font-size: 14px; font-weight: 800; color: var(--bem-text, #2d2b3d);
}
.bem-pwa-banner__text span {
  font-size: 12px; color: var(--bem-text-muted, #7c7a8a);
}
.bem-pwa-banner__actions {
  display: flex; align-items: center; gap: 8px;
}
.bem-pwa-banner__btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff; border: none; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .2s;
  box-shadow: 0 2px 10px rgba(124,58,237,.25);
}
.bem-pwa-banner__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124,58,237,.35);
}
.bem-pwa-banner__close {
  width: 32px; height: 32px;
  background: transparent; border: none;
  font-size: 22px; color: var(--bem-text-light, #a5a3b3);
  cursor: pointer; border-radius: 50%;
  transition: all .2s; display: flex; align-items: center; justify-content: center;
}
.bem-pwa-banner__close:hover {
  background: var(--bem-bg, #f8f7ff); color: var(--bem-text, #2d2b3d);
}

@keyframes bemSlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .bem-pwa-banner { padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
  .bem-pwa-banner__actions { width: 100%; justify-content: flex-end; }
}

/* Dark mode */
.bem-dark .bem-pwa-banner {
  background: var(--bem-surface); border-color: var(--bem-border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.4);
}

/* Hide banner when app is already installed */
@media (display-mode: standalone) {
  .bem-pwa-banner { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */
@keyframes bemFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bemSpin { to { transform: rotate(360deg); } }
@keyframes bemPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}
@keyframes bemDropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bemSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════════════ */
.bem-dark {
  --bem-primary:      #a78bfa;
  --bem-primary-dark: #7c3aed;
  --bem-primary-light:#2e1065;
  --bem-gold:         #fb923c;
  --bem-gold-dark:    #f97316;
  --bem-gold-light:   #431407;
  --bem-success:      #34d399;
  --bem-success-light:#064e3b;
  --bem-danger:       #f87171;
  --bem-danger-light: #450a0a;
  --bem-bg:           #0f0a1a;
  --bem-surface:      #1a1230;
  --bem-border:       #2d2250;
  --bem-text:         #e2e8f0;
  --bem-text-muted:   #94a3b8;
  --bem-text-light:   #64748b;
  --bem-shadow:       0 2px 12px rgba(0,0,0,.3);
  --bem-shadow-lg:    0 8px 32px rgba(0,0,0,.4);
}

/* ─── Dark mode: hardcoded color overrides ────────────────────── */
.bem-dark .bem-lesson-content,
.bem-dark .bem-exercise-content { color: var(--bem-text); }

/* Lesson content — dark mode overrides */
.bem-dark .bem-lesson-content h3 {
  color: #6ee7b7 !important;
  background: linear-gradient(to left, #064e3b55, #064e3b33) !important;
  border-right-color: #34d399 !important;
}
.bem-dark .bem-lesson-content .quran-block {
  background: linear-gradient(135deg, #052e1e, #0a2419) !important;
  border-color: #064e3b !important;
  border-right-color: #34d399 !important;
  color: #d1fae5 !important;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.bem-dark .bem-lesson-content .bismillah {
  color: #6ee7b7 !important;
  border-bottom-color: #064e3b !important;
}
.bem-dark .bem-lesson-content .ayah { color: #a7f3d0 !important; }
.bem-dark .bem-lesson-content td {
  border-color: #064e3b !important;
  color: var(--bem-text);
}
.bem-dark .bem-lesson-content tr:nth-child(even) td { background: #0a2419 !important; }
.bem-dark .bem-lesson-content th {
  background: #064e3b !important;
  color: #d1fae5 !important;
}
.bem-dark .bem-lesson-content ol li,
.bem-dark .bem-lesson-content ul li { color: var(--bem-text); }

.bem-dark .bem-solution-box {
  background: linear-gradient(135deg, #064e3b, #052e26);
  border-right-color: #10b981;
}
.bem-dark .bem-solution-title,
.bem-dark .bem-solution-content { color: #6ee7b7; }

.bem-dark .bem-msg--error   { background: var(--bem-danger-light); color: #fca5a5; border-right-color: #f87171; }
.bem-dark .bem-msg--success { background: var(--bem-success-light); color: #6ee7b7; border-right-color: #34d399; }

.bem-dark .bem-notice--info { color: #c4b5fd; }

/* Dark mode: auth page background */
.bem-dark .bem-auth-page { background: var(--bem-bg); }
.bem-dark .bem-auth { background: var(--bem-surface); border-color: var(--bem-border); }

.bem-dark .bem-google-btn {
  background: var(--bem-surface); border-color: var(--bem-border); color: var(--bem-text);
}
.bem-dark .bem-google-btn:hover { background: #241a40; }

.bem-dark .bem-sidebar-title { background: linear-gradient(135deg, #1a1230, #150f28); }
.bem-dark .bem-sidebar-item  { border-bottom-color: var(--bem-border); }

.bem-dark .bem-star.inactive { color: #374151; }

.bem-dark .bem-badge--active   { background: #064e3b; color: #6ee7b7; }
.bem-dark .bem-badge--inactive { background: #1e1b2e; color: var(--bem-text-muted); }
.bem-dark .bem-badge--expired  { background: #450a0a; color: #fca5a5; }

.bem-dark .bem-progress   { background: #2d2250; }
.bem-dark .bem-error      { background: #450a0a; color: #fca5a5; border-right-color: #f87171; }

.bem-dark .bem-sub-row    { border-bottom-color: var(--bem-border); }
.bem-dark .bem-days-left  { background: #064e3b; color: #6ee7b7; }
.bem-dark .bem-days-left--urgent { background: #450a0a; color: #fca5a5; }

.bem-dark .bem-readiness-bar-lg,
.bem-dark .bem-readiness-bar-sm { background: #2d2250; }

.bem-dark .bem-jxg { background: #1a1230; border-color: var(--bem-border); }

.bem-dark .bem-exercise-header { border-bottom-color: var(--bem-border); }
.bem-dark .bem-readiness-subject { border-bottom-color: var(--bem-border); }
.bem-dark .bem-card__title  { border-bottom-color: var(--bem-border); }
.bem-dark .bem-card__title-inline { color: var(--bem-text); }
.bem-dark .bem-btn--outline-sm { color: var(--bem-text-muted); border-color: var(--bem-border); }
.bem-dark .bem-btn--outline-sm:hover { color: var(--bem-primary); border-color: var(--bem-primary); background: rgba(139,92,246,.1); }
.bem-dark .bem-btn--logout { color: var(--bem-text-light); border-color: var(--bem-border); }
.bem-dark .bem-btn--logout:hover { color: #f87171; border-color: #f87171; background: rgba(248,113,113,.1); }
.bem-dark .bem-btn--primary-lg { box-shadow: 0 4px 16px rgba(139,92,246,.3); }

/* ─── Smooth transitions for dark mode ────────────────────────── */
.bem-auth, .bem-dashboard, #bem-platform-root,
.bem-card, .bem-sidebar, .bem-grid-item,
.bem-exercise-card, .bem-lesson-box, .bem-breadcrumb,
.bem-gate-wrap, .bem-gate-card, .bem-empty,
.bem-section-title, .bem-exercise-tabs, .bem-tab {
  transition: background-color .3s, color .3s, border-color .3s, box-shadow .3s;
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════ */
.bem-dark-toggle {
  width: 40px; height: 40px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.1);
  cursor: pointer; font-size: 18px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; color: #fff; line-height: 1;
}
.bem-dark-toggle:hover {
  border-color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.2);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   ACCOUNT MENU
   ═══════════════════════════════════════════════════════════════ */
.bem-account-menu {
  position: fixed; top: 12px; right: 20px; z-index: 10000;
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  direction: rtl;
}
.bem-account-trigger {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4);
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .25s;
  box-shadow: 0 4px 16px rgba(139,92,246,.25);
}
.bem-account-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(139,92,246,.35);
  border-color: rgba(255,255,255,.6);
}
.bem-account-avatar {
  color: #fff; font-weight: 800; font-size: 17px;
  font-family: 'Tajawal', sans-serif; line-height: 1;
}
.bem-account-avatar--lg {
  width: 54px; height: 54px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(139,92,246,.2);
}

.bem-account-dropdown {
  display: none; position: absolute;
  top: calc(100% + 10px); right: 0;
  min-width: 290px;
  background: var(--bem-surface, #ffffff);
  border: 1px solid var(--bem-border, #ebe5f6);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(139,92,246,.12);
  padding: 8px 0;
  animation: bemDropIn .2s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.bem-account-dropdown.open { display: block; }

.bem-account-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px 14px;
}
.bem-account-name {
  font-weight: 800; font-size: 16px;
  color: var(--bem-text, #1e293b);
}
.bem-account-email {
  font-size: 13px; color: var(--bem-text-muted, #64748b); margin-top: 3px;
  direction: ltr; text-align: right;
}
.bem-account-divider {
  height: 1px;
  background: var(--bem-border, #e2e8f0);
  margin: 6px 14px;
}
.bem-account-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; font-size: 14px; font-weight: 600;
  color: var(--bem-text, #1e293b); text-decoration: none;
  cursor: pointer; border: none; background: none; width: 100%;
  font-family: 'Tajawal', sans-serif; transition: background .15s;
  line-height: 1;
}
.bem-account-item:hover { background: var(--bem-primary-light, #ede9fe); }
.bem-account-item--danger { color: #ef4444; }
.bem-account-item--danger:hover { background: #fef2f2; }
.bem-dark .bem-account-item--danger:hover { background: #450a0a; }
.bem-dark .bem-account-dropdown { box-shadow: 0 16px 48px rgba(0,0,0,.4); }

/* ─── Logged-out controls (dark toggle only) ─────────────────── */
.bem-guest-controls {
  position: fixed; top: 12px; right: 20px; z-index: 10000;
  display: flex; align-items: center; gap: 8px;
}
.bem-guest-controls .bem-dark-toggle {
  border-color: var(--bem-border, #e2e8f0);
  background: var(--bem-surface, #fff);
  color: var(--bem-text, #1e293b);
}
.bem-dark .bem-guest-controls .bem-dark-toggle {
  border-color: #2d2250; background: #1a1230; color: #e2e8f0;
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGE IMPROVEMENTS
   ═══════════════════════════════════════════════════════════════ */
.bem-auth-page {
  min-height: 80vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 16px;
  background: var(--bem-bg);
}
.bem-auth-page .bem-auth {
  background: var(--bem-surface);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--bem-shadow-lg);
  border: 1px solid var(--bem-border);
  width: 100%; max-width: 440px;
}
.bem-auth-page .bem-auth__brand-logo {
  width: 80px; height: 80px;
  border-radius: 24px; font-size: 36px;
  box-shadow: 0 10px 32px rgba(139,92,246,.25);
}

/* Animated messages */
.bem-msg--error, .bem-msg--success {
  animation: bemSlideDown .3s ease;
}

/* Better focus */
.bem-form-group input:focus {
  box-shadow: 0 0 0 4px rgba(124,58,237,.15);
}
.bem-dark .bem-form-group input:focus {
  box-shadow: 0 0 0 4px rgba(167,139,250,.2);
}

/* ═══════════════════════════════════════════════════════════════
   UI POLISH & MICRO-INTERACTIONS
   ═══════════════════════════════════════════════════════════════ */

/* Cards lift on hover */
.bem-grid-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(124,58,237,.15);
}

/* Better focus-visible outlines */
:focus-visible {
  outline: 2px solid var(--bem-primary);
  outline-offset: 2px;
}


/* ═══════════════════════════════════════════════════════════════
   ACCOUNT MENU RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .bem-account-menu,
  .bem-guest-controls { top: 8px; right: 12px; }
  .bem-account-trigger { width: 38px; height: 38px; }
  .bem-account-avatar { font-size: 15px; }
  .bem-account-dropdown { min-width: 260px; right: 0; left: auto; }
  .bem-topbar .bem-topbar-right { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════
   MUSHAF — عرض القرآن الكريم
   ═══════════════════════════════════════════════════════════════ */
/* Amiri Quran font loaded via PHP enqueue — no @import needed */

.mushaf-surah {
  direction: rtl;
  margin: 0 0 28px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(21,128,61,.12);
  border: 1px solid #bbf7d0;
}

/* رأس السورة */
.mushaf-header {
  background: linear-gradient(135deg, #14532d 0%, #166534 50%, #15803d 100%);
  color: #fff;
  text-align: center;
  padding: 22px 20px 18px;
  position: relative;
}
.mushaf-header::before,
.mushaf-header::after {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.4), transparent);
}
.mushaf-header::before { margin-bottom: 14px; }
.mushaf-header::after  { margin-top: 14px; }

.mushaf-surah-name {
  font-family: 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif;
  font-size: 2em;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fef9c3;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
  margin-bottom: 8px;
}
.mushaf-surah-meta {
  font-size: 13px;
  color: rgba(255,255,255,.8);
  letter-spacing: .5px;
}

/* البسملة */
.mushaf-basmala {
  font-family: 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif;
  font-size: 1.9em;
  text-align: center;
  color: #14532d;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  padding: 20px 24px;
  border-bottom: 1px solid #bbf7d0;
  line-height: 1.8;
  letter-spacing: 1px;
}

/* نص الآيات */
.mushaf-text {
  font-family: 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif;
  font-size: 1.55em;
  line-height: 2.8;
  text-align: justify;
  direction: rtl;
  background: #fffef7;
  padding: 28px 32px;
  color: #1a1a0a;
  word-spacing: 4px;
}

/* كل آية */
.mushaf-ayah {
  display: inline;
}

/* رقم الآية ۝ */
.mushaf-ayah-num {
  font-family: 'Amiri Quran', 'Scheherazade New', serif;
  font-size: .7em;
  color: #15803d;
  vertical-align: middle;
  margin: 0 2px 0 4px;
  display: inline-block;
}

/* ─── Dark mode ───────────────────────────────────────────────── */
.bem-dark .mushaf-surah { border-color: #064e3b; box-shadow: 0 4px 24px rgba(0,0,0,.4); }
.bem-dark .mushaf-basmala {
  background: linear-gradient(135deg, #052e1e, #064e3b);
  color: #6ee7b7;
  border-bottom-color: #064e3b;
}
.bem-dark .mushaf-text { background: #0f1a13; color: #e8f5e9; }
.bem-dark .mushaf-ayah-num { color: #34d399; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mushaf-text     { font-size: 1.3em; padding: 20px 18px; line-height: 2.6; }
  .mushaf-basmala  { font-size: 1.5em; }
  .mushaf-surah-name { font-size: 1.6em; }
}
@media (max-width: 480px) {
  .mushaf-text     { font-size: 1.15em; padding: 16px 14px; }
  .mushaf-basmala  { font-size: 1.3em; }
}

/* ═══════════════════════════════════════════════════════════════
   ISLAMIC EDUCATION — تربية إسلامية
   ═══════════════════════════════════════════════════════════════ */

/* ─── Section Headers ────────────────────────────────────────── */
.isl-section {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-size: 1.08em !important;
  font-weight: 800 !important;
  color: #14532d !important;
  margin: 26px 0 14px !important;
  padding: 11px 16px 11px 12px !important;
  background: linear-gradient(to left, #f0fdf4, #dcfce7) !important;
  border-right: 5px solid #16a34a !important;
  border-radius: 0 10px 10px 0 !important;
  border-bottom: none !important;
  box-shadow: 0 2px 8px rgba(22,163,74,.08) !important;
}
.isl-section::before {
  content: '❖';
  color: #16a34a;
  font-size: .72em;
  flex-shrink: 0;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.isl-table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 18px 0 !important;
  direction: rtl !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  box-shadow: 0 2px 14px rgba(22,163,74,.1) !important;
  font-size: 15px !important;
}
.isl-table th {
  background: linear-gradient(135deg, #15803d, #166534) !important;
  color: #fff !important;
  padding: 12px 18px !important;
  text-align: center !important;
  font-weight: 700 !important;
  border: none !important;
}
.isl-table td {
  padding: 11px 18px !important;
  border: 1px solid #d1fae5 !important;
  vertical-align: top !important;
  line-height: 1.8 !important;
  word-wrap: break-word !important;
}
.isl-table tr:nth-child(even) td { background: #f0fdf4 !important; }
.isl-table tr:hover td { background: #dcfce7 !important; transition: background .15s; }

/* ─── Ordered Lists ──────────────────────────────────────────── */
.isl-list {
  padding: 0 !important;
  margin: 14px 0 18px !important;
  list-style: none !important;
  counter-reset: isl-counter !important;
}
.isl-list > li {
  counter-increment: isl-counter !important;
  display: flex !important;
  align-items: flex-start !important;
  gap: 14px !important;
  padding: 10px 4px !important;
  border-bottom: 1px solid #f0fdf4 !important;
  line-height: 1.85 !important;
  margin: 0 !important;
}
.isl-list > li:last-child { border-bottom: none !important; }
.isl-list > li::before {
  content: counter(isl-counter) !important;
  min-width: 30px !important;
  height: 30px !important;
  background: linear-gradient(135deg, #15803d, #166534) !important;
  color: #fff !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  flex-shrink: 0 !important;
  box-shadow: 0 2px 6px rgba(22,163,74,.25) !important;
}

/* ─── Type Grid (أنواع الحج / الصلاة …) ─────────────────────── */
.isl-type-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)) !important;
  gap: 14px !important;
  margin: 18px 0 !important;
  direction: rtl !important;
}
.isl-type-card {
  background: #fff !important;
  border-radius: 12px !important;
  padding: 18px 14px !important;
  text-align: center !important;
  border: 2px solid #d1fae5 !important;
  box-shadow: 0 3px 10px rgba(22,163,74,.08) !important;
  transition: transform .2s, box-shadow .2s !important;
  line-height: 1.7 !important;
}
.isl-type-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 22px rgba(22,163,74,.16) !important;
}
.isl-type-card strong, .isl-type-card b {
  display: block !important;
  color: #15803d !important;
  font-size: 1.1em !important;
  font-weight: 800 !important;
  margin-bottom: 6px !important;
}

/* ─── Info Box (شروط / حِكَم …) ─────────────────────────────── */
.isl-info-box {
  background: #f0fdf4 !important;
  border-right: 5px solid #16a34a !important;
  border-radius: 0 10px 10px 0 !important;
  padding: 16px 20px !important;
  margin: 16px 0 !important;
  box-shadow: 0 2px 8px rgba(22,163,74,.07) !important;
}

/* ─── Quran block — enhanced ─────────────────────────────────── */
.bem-lesson-content .quran-block {
  font-family: "Scheherazade New", "Amiri", "Traditional Arabic", Georgia, serif !important;
  font-size: 1.32em !important;
  line-height: 3.4 !important;
  text-align: justify !important;
  background: linear-gradient(160deg, #f8fdf9 0%, #f0fdf4 100%) !important;
  border: 1px solid #bbf7d0 !important;
  border-right: 6px solid #16a34a !important;
  border-radius: 0 12px 12px 0 !important;
  padding: 22px 28px 18px 18px !important;
  margin: 22px 0 !important;
  direction: rtl !important;
  position: relative !important;
  box-shadow: 0 4px 20px rgba(22,163,74,.09) !important;
}
.bem-lesson-content .bismillah {
  text-align: center !important;
  font-size: 1.22em !important;
  color: #15803d !important;
  font-weight: 800 !important;
  margin-bottom: 16px !important;
  padding-bottom: 14px !important;
  border-bottom: 1px dashed #86efac !important;
  display: block !important;
  letter-spacing: .5px !important;
}
.bem-lesson-content .ayah {
  color: #14532d !important;
  display: inline !important;
}

/* ─── Dark mode — Islamic ────────────────────────────────────── */
.bem-dark .isl-section {
  color: #6ee7b7 !important;
  background: linear-gradient(to left, rgba(6,78,59,.4), rgba(5,46,30,.3)) !important;
  border-right-color: #34d399 !important;
}
.bem-dark .isl-section::before { color: #34d399; }
.bem-dark .isl-table th {
  background: linear-gradient(135deg, #064e3b, #052e1e) !important;
}
.bem-dark .isl-table td { border-color: #064e3b !important; color: var(--bem-text) !important; }
.bem-dark .isl-table tr:nth-child(even) td { background: #052e1e !important; }
.bem-dark .isl-table tr:hover td { background: #0a2419 !important; }
.bem-dark .isl-type-card {
  background: #1a1230 !important;
  border-color: #064e3b !important;
}
.bem-dark .isl-type-card strong,
.bem-dark .isl-type-card b { color: #6ee7b7 !important; }
.bem-dark .isl-list > li { border-bottom-color: #064e3b !important; }
.bem-dark .isl-list > li::before {
  background: linear-gradient(135deg, #064e3b, #052e1e) !important;
}
.bem-dark .isl-info-box {
  background: rgba(5,46,30,.5) !important;
  border-right-color: #34d399 !important;
}
.bem-dark .bem-lesson-content .quran-block {
  background: linear-gradient(160deg, #052e1e 0%, #0a2419 100%) !important;
  border-color: #064e3b !important;
  border-right-color: #34d399 !important;
  color: #d1fae5 !important;
}
.bem-dark .bem-lesson-content .bismillah {
  color: #6ee7b7 !important;
  border-bottom-color: #064e3b !important;
}
.bem-dark .bem-lesson-content .ayah { color: #a7f3d0 !important; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .isl-table { font-size: 13.5px !important; display: block; overflow-x: auto; }
  .isl-type-grid { grid-template-columns: 1fr 1fr !important; }
  .bem-lesson-content .quran-block { font-size: 1.15em !important; padding: 16px 18px 14px !important; }
  .isl-section { font-size: 1em !important; }
}
@media (max-width: 480px) {
  .isl-type-grid { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════════
   CONTENT PROTECTION — منع النسخ والتحميل
   ═══════════════════════════════════════════════════════════════ */

/* منع التحديد والنسخ على كل محتوى المنصة */
#bem-platform-root,
.bem-lesson-content,
.bem-exercise-card,
#main-content,
#lesson-content,
.bem-content-body {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

/* السماح بالنسخ في حقول الإدخال فقط */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* ═══════════════════════════════════════════════════════════════
   معرض الصور التوضيحية — bem-figures-gallery
   يُستخدم في دروس التاريخ والجغرافيا والعلوم
   ═══════════════════════════════════════════════════════════════ */

.bem-figures-gallery {
  margin: 28px 0;
  padding: 22px 20px;
  background: #f8f7ff;
  border: 1px solid #ebe5f6;
  border-radius: 14px;
}

.bem-figures-gallery .isl-section {
  margin-top: 0;
  margin-bottom: 18px;
}

.bem-figures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.bem-figure {
  margin: 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(139,92,246,.08);
  border: 1px solid #ebe5f6;
  display: flex;
  flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}

.bem-figure:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(139,92,246,.15);
}

.bem-figure img {
  width: 100% !important;
  height: 200px;
  object-fit: cover;
  display: block;
  pointer-events: auto !important;
  -webkit-user-drag: auto !important;
}

.bem-figure figcaption {
  padding: 10px 14px;
  font-size: .82em;
  color: #5b5478;
  line-height: 1.5;
  border-top: 1px solid #f0ecff;
  background: #faf9ff;
  flex: 1;
  direction: rtl;
  text-align: right;
}

/* تخطيط مرن للصور التاريخية (portrait) */
.bem-figures-gallery.portrait .bem-figures-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.bem-figures-gallery.portrait .bem-figure img {
  height: 240px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .bem-figures-gallery { background: #1a1826; border-color: #2d2a45; }
  .bem-figure { background: #22203a; border-color: #2d2a45; }
  .bem-figure figcaption { background: #1e1c35; color: #b8b0d8; border-color: #2d2a45; }
}

/* Responsive */
@media (max-width: 600px) {
  .bem-figures-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .bem-figure img { height: 140px; }
}
@media (max-width: 380px) {
  .bem-figures-grid { grid-template-columns: 1fr; }
}

/* ───────────────────────────────────────────────────────────── */

/* منع Drag للصور */
#bem-platform-root img,
.bem-lesson-content img {
  -webkit-user-drag: none !important;
  pointer-events: none !important;
}
