/* ============================================================
   نظام التصميم الجديد — ألوان Tajawal + وضع داكن يدوي
   يُطبَّق على التخطيط الحالي دون تغيير البنية أو معرفات العناصر
   ============================================================ */
:root {
  --bg: #f3f6f6;
  --surface: #ffffff;
  --ink: #14282b;
  --muted: #5b6f72;
  --line: #d5e0e0;
  --brand: #0f5c5c;
  --brand-ink: #ffffff;
  --soft: #e2f0ef;
  --accent: #e8a317;
  --accent-ink: #2a1d00;
  --danger: #b3372f;
  --danger-ink: #ffffff;
  --secondary: #475569;
  --exam: #1e5fb3;
  --ok: #198754;
  --ok-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1c1e;
    --surface: #152a2d;
    --ink: #e6f1f0;
    --muted: #92abad;
    --line: #254043;
    --brand: #4fb3ad;
    --brand-ink: #06201f;
    --soft: #1b3639;
    --accent: #f0b43a;
    --accent-ink: #2a1d00;
    --danger: #ef8077;
    --danger-ink: #2a1d00;
    --secondary: #475569;
    --exam: #3b82c4;
    --ok: #4ade80;
    --ok-ink: #06201f;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1c1e;
  --surface: #152a2d;
  --ink: #e6f1f0;
  --muted: #92abad;
  --line: #254043;
  --brand: #4fb3ad;
  --brand-ink: #06201f;
  --soft: #1b3639;
  --accent: #f0b43a;
  --accent-ink: #2a1d00;
  --danger: #ef8077;
  --danger-ink: #2a1d00;
  --secondary: #475569;
  --exam: #3b82c4;
  --ok: #4ade80;
  --ok-ink: #06201f;
}

/* الخط الجديد */
body, input, select, textarea, button {
  font-family: "Tajawal", system-ui, "Segoe UI", Tahoma, sans-serif !important;
}

/* الخلفيات والنصوص الأساسية */
html { background: var(--bg) !important; }
body { background: var(--bg) !important; color: var(--ink) !important; }
@media (min-width: 560px) {
  html { background: var(--bg) !important; }
  body { background: var(--surface) !important; border-color: var(--line) !important; }
}

.header { flex-wrap: wrap; border-bottom-color: var(--line) !important; }
.title-with-count h2 { color: var(--ink) !important; }
.badge { background: var(--accent) !important; color: var(--accent-ink) !important; }
.status-box { background: var(--soft) !important; }

/* الأزرار حسب الأصناف الحالية (بدون تغيير أي معرّف) */
.btn-primary { background: var(--brand) !important; color: var(--brand-ink) !important; }
.btn-secondary { background: var(--secondary) !important; color: #ffffff !important; }
.btn-teacher { background: var(--brand) !important; color: var(--brand-ink) !important; }
.btn-exam { background: var(--exam) !important; color: #ffffff !important; }
.btn-danger { background: var(--danger) !important; color: var(--danger-ink) !important; }
.btn-primary:hover, .btn-secondary:hover, .btn-teacher:hover,
.btn-exam:hover, .btn-danger:hover { filter: brightness(0.92) !important; }
button { border-radius: 8px !important; }

/* أزرار ذات ألوان مضمّنة في التخطيط الحالي */
button[style*="background:#0d6efd"], button[style*="background:#0b5ed7"],
button[style*="background:#0d9488"], button[style*="background:#0f766e"] {
  background-color: var(--brand) !important; color: var(--brand-ink) !important;
}
button[style*="background:#475569"], button[style*="background:#6c757d"] {
  background-color: var(--secondary) !important; color: #ffffff !important;
}
button[style*="background:#dc3545"] {
  background-color: var(--danger) !important; color: var(--danger-ink) !important;
}
button[style*="background:#198754"] {
  background-color: var(--ok) !important; color: var(--ok-ink) !important;
}

/* البطاقات القابلة للطي */
.collapsible-questions, .collapsible-share, .collapsible-correction {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}
.collapsible-questions summary, .collapsible-share summary, .collapsible-correction summary {
  background: var(--soft) !important;
  color: var(--brand) !important;
}
.collapsible-questions summary:hover, .collapsible-share summary:hover,
.collapsible-correction summary:hover { filter: brightness(0.95) !important; }
.questions-container::-webkit-scrollbar-thumb { background: var(--line) !important; }

/* الحقول */
input, select, textarea {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}
::placeholder { color: var(--muted) !important; opacity: 0.85; }

/* التذييل */
.footer-credits {
  background: var(--brand) !important;
  color: var(--brand-ink) !important;
  border-top-color: var(--accent) !important;
}
.footer-credits a { color: var(--accent) !important; }

/* خلفيات وحدود مضمّنة في التخطيط الحالي */
[style*="background:#f8fafc"], [style*="background:#f8f9fa"],
[style*="background:#fff"], [style*="background:#ffffff"] {
  background-color: var(--surface) !important;
}
[style*="background:#f0fdf4"], [style*="background:#ccfbf1"] {
  background-color: var(--soft) !important;
}
[style*="background:#fffbeb"] { background-color: rgba(232, 163, 23, 0.14) !important; }
[style*="border:1px solid #cbd5e1"], [style*="border:1px solid #e2e8f0"],
[style*="border:1px solid #86efac"], [style*="border:1px solid #fde68a"] {
  border-color: var(--line) !important;
}

/* ألوان نصوص مضمّنة — مع استبعاد #status لأن لونه يتغير ديناميكياً */
[style*=";color:#1e293b"], [style^="color:#1e293b"],
[style*=";color:#475569"], [style^="color:#475569"],
[style*=";color:#334155"], [style^="color:#334155"],
[style*=";color:#64748b"], [style^="color:#64748b"] { color: var(--ink) !important; }
[style*=";color:#0f766e"], [style^="color:#0f766e"],
[style*=";color:#166534"], [style^="color:#166534"] { color: var(--brand) !important; }
[style*=";color:#92400e"], [style^="color:#92400e"] { color: var(--accent) !important; }

/* زر تبديل الوضع الداكن */
#fawriThemeBtn {
  flex: 0 0 auto !important;
  min-height: auto !important;
  font-size: 16px !important;
  line-height: 1.2;
  padding: 4px 8px !important;
  border: 1px solid var(--line) !important;
  background: var(--soft) !important;
  color: var(--brand) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  white-space: nowrap;
}
#fawriThemeBtn:hover { filter: brightness(0.94) !important; }
