/* ==========================================================
   مدارك — طبقة الأنماط الإضافية (الوضع الليلي + لمسات الحركة)
   ========================================================== */

:root {
  --app-bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e2e8f0;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
}

html.dark {
  --app-bg: #070d18;
  --surface: #111a2c;
  --surface-2: #0d1524;
  --surface-3: #182338;
  --line: #23314a;
  --ink: #e9eefb;
  --ink-2: #cad6ea;
  --ink-3: #9aabc7;
  --ink-4: #7488a8;
}

html body {
  background-color: var(--app-bg);
  color: var(--ink);
  transition: background-color .25s ease, color .25s ease;
}

/* حركة دخول خفيفة لكل شاشة */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-enter { animation: viewIn .22s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .view-enter { animation: none; }
  html body { transition: none; }
  .log-chart-bar, .log-level-bar { transition: none; }
}

/* إبراز التركيز للوحة المفاتيح */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* ================= الوضع الليلي ================= */

html.dark .bg-white { background-color: var(--surface); }
html.dark .bg-white\/95 { background-color: rgba(17, 26, 44, .94); }

html.dark .bg-slate-50 { background-color: var(--surface-2); }
html.dark .bg-slate-50\/70 { background-color: rgba(13, 21, 36, .72); }
html.dark .bg-slate-50\/80 { background-color: rgba(13, 21, 36, .82); }
html.dark .bg-slate-100 { background-color: var(--surface-3); }
html.dark .bg-slate-100\/70 { background-color: rgba(24, 35, 56, .72); }
html.dark .bg-slate-100\/90 { background-color: rgba(24, 35, 56, .9); }
html.dark .bg-slate-200 { background-color: #1f2c45; }

/* الحدود */
html.dark .border-slate-100,
html.dark .border-slate-100\/80,
html.dark .border-slate-200,
html.dark .border-slate-200\/60,
html.dark .border-slate-200\/70,
html.dark .border-slate-200\/80,
html.dark .border-slate-200\/90,
html.dark .border-slate-300 { border-color: var(--line); }

/* النصوص */
html.dark .text-slate-900,
html.dark .text-slate-800 { color: var(--ink); }
html.dark .text-slate-700 { color: var(--ink-2); }
html.dark .text-slate-600,
html.dark .text-slate-500 { color: var(--ink-3); }
html.dark .text-slate-400,
html.dark .text-slate-300 { color: var(--ink-4); }

/* التظليلات اللونية الخفيفة */
html.dark .bg-brand-50,
html.dark .bg-brand-50\/50,
html.dark .bg-blue-50 { background-color: rgba(37, 99, 235, .16); }
html.dark .bg-brand-100 { background-color: rgba(37, 99, 235, .26); }
html.dark .bg-indigo-50 { background-color: rgba(99, 102, 241, .16); }
html.dark .bg-cyan-50 { background-color: rgba(6, 182, 212, .14); }
html.dark .bg-emerald-50,
html.dark .bg-emerald-50\/70,
html.dark .bg-emerald-50\/80 { background-color: rgba(16, 185, 129, .14); }
html.dark .bg-emerald-100 { background-color: rgba(16, 185, 129, .22); }
html.dark .bg-amber-50,
html.dark .bg-amber-50\/80 { background-color: rgba(245, 158, 11, .15); }
html.dark .bg-amber-100 { background-color: rgba(245, 158, 11, .22); }
html.dark .bg-rose-50 { background-color: rgba(244, 63, 94, .15); }
html.dark .bg-rose-100 { background-color: rgba(244, 63, 94, .22); }

/* نصوص الألوان على الخلفيات الداكنة */
html.dark .text-brand-800,
html.dark .text-brand-700 { color: #9dbcff; }
html.dark .text-brand-600,
html.dark .text-brand-500 { color: #7aa7ff; }
html.dark .text-indigo-700,
html.dark .text-indigo-600,
html.dark .text-indigo-500 { color: #a7aeff; }
html.dark .text-cyan-700,
html.dark .text-cyan-600 { color: #67e0f2; }
html.dark .text-emerald-950,
html.dark .text-emerald-900,
html.dark .text-emerald-800,
html.dark .text-emerald-600,
html.dark .text-emerald-500 { color: #6fe3b4; }
html.dark .text-amber-950,
html.dark .text-amber-900,
html.dark .text-amber-600,
html.dark .text-amber-500 { color: #f2c169; }
html.dark .text-rose-900,
html.dark .text-rose-800,
html.dark .text-rose-700,
html.dark .text-rose-600,
html.dark .text-rose-400 { color: #ff9db0; }

/* حدود الألوان الخفيفة */
html.dark .border-brand-100,
html.dark .border-brand-200,
html.dark .border-brand-200\/80,
html.dark .border-brand-300,
html.dark .border-blue-100,
html.dark .border-blue-200 { border-color: rgba(96, 165, 250, .32); }
html.dark .border-emerald-200,
html.dark .border-emerald-200\/80,
html.dark .border-emerald-300,
html.dark .border-emerald-400 { border-color: rgba(16, 185, 129, .35); }
html.dark .border-amber-200,
html.dark .border-amber-200\/80,
html.dark .border-amber-300 { border-color: rgba(245, 158, 11, .35); }
html.dark .border-rose-200,
html.dark .border-rose-300 { border-color: rgba(244, 63, 94, .35); }
html.dark .border-indigo-200,
html.dark .border-indigo-200\/80 { border-color: rgba(99, 102, 241, .35); }
html.dark .border-cyan-100 { border-color: rgba(6, 182, 212, .3); }

/* الحقول */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: var(--surface-3);
  color: var(--ink);
  border-color: var(--line);
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: var(--ink-4); }
html.dark input[type="date"],
html.dark input[type="time"] { color-scheme: dark; }

/* حالات التمرير */
html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-brand-50:hover,
html.dark .hover\:bg-slate-200:hover { background-color: var(--surface-3); }
html.dark .hover\:text-slate-900:hover { color: var(--ink); }

/* مخطط سجل النقاط */
html.dark .log-chart-bar.is-empty { background: #1f2c45; }
html.dark .log-chart-value,
html.dark .log-chart-label { color: var(--ink-4); }
html.dark .log-chart-label.is-today { color: #7aa7ff; }

/* الأزرار المعطّلة */
html.dark .disabled\:bg-slate-200:disabled { background-color: #1c2942; }
html.dark .disabled\:text-slate-400:disabled { color: var(--ink-4); }