/* خط Tajawal مضمَّن مع المشروع (يعمل بدون إنترنت) */
@font-face { font-family: "Tajawal"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Tajawal-Regular.ttf") format("truetype"); }
@font-face { font-family: "Tajawal"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Tajawal-Medium.ttf") format("truetype"); }
@font-face { font-family: "Tajawal"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Tajawal-Bold.ttf") format("truetype"); }
@font-face { font-family: "Tajawal"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/Tajawal-ExtraBold.ttf") format("truetype"); }

:root {
  color-scheme: light;
  --text: #1d1c3a;
  --surface: #ffffff;     /* خلفية الحقول والأزرار الثانوية */
  --soft: #efeef9;
  --soft2: #f1f0f8;
  --ph: #b9b7d1;
  --on-ink: #ffffff;      /* لون النص فوق خلفية --ink */
  --bar: rgba(250, 249, 253, .94);
  --foot: #a3a1bd;
  --toast: #1d1c3a;
  --danger-bg: #fdeceb;
  --danger-line: #e5b9b6;
  --focus: rgba(123, 63, 160, .45);
  --ink: #2c2a6e;        /* نيلي الشعار */
  --ink-soft: #46439a;
  --accent: #7b3fa0;     /* بنفسجي الشعار */
  --bg: #faf9fd;
  --card: #ffffff;
  --line: #e6e4f0;
  --muted: #6b6a85;
  --danger: #b3261e;
  --ok: #1b7a43;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(44, 42, 110, .06), 0 6px 20px rgba(44, 42, 110, .06);
  --warn-bg: #fff6dd; --warn-line: #f0dc9a; --warn-text: #6a5200;
  --line-hover: #cfcbe8; --checked: #f5f4fc;
  --font: "Tajawal", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;   /* Tajawal أصغر بصرياً من Cairo فنكبّره قليلاً */
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* رؤوس الصفحات */
.brand { text-align: center; padding: 22px 16px 6px; }
.brand img { height: 84px; width: auto; margin: 0 auto; }

/* أزرار */
.btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--on-ink);
  padding: 10px 20px;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: transparent; border-color: var(--danger-line); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { min-height: 36px; padding: 4px 14px; font-size: 14px; border-radius: 10px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* حقول */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-weight: 700; font-size: 14px; color: var(--ink); }
.input {
  width: 100%;
  min-height: 46px;
  padding: 9px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(123, 63, 160, .15); }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.error-text { color: var(--danger); font-size: 14px; min-height: 22px; margin: 0; }

.muted { color: var(--muted); }
.toast {
  position: fixed; inset-inline: 0; bottom: 22px; margin: 0 auto; width: fit-content; max-width: 90vw;
  background: var(--toast); color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 15px;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

/* ===== الوضع الداكن ===== */
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e4e1ff;
  --ink-soft: #cfc9ff;
  --accent: #c9a2ea;
  --bg: #141330;
  --card: #1e1c47;
  --surface: #1e1c47;
  --soft: #2b2961;
  --soft2: #272559;
  --line: #36346f;
  --line-hover: #4b4895;
  --checked: #2b2961;
  --muted: #a9a7cc;
  --text: #f1efff;
  --ph: #5f5c99;
  --on-ink: #1a1840;
  --bar: rgba(20, 19, 48, .92);
  --foot: #6d6aa3;
  --toast: #3a3880;
  --danger: #ff8f86;
  --danger-bg: #3a1d27;
  --danger-line: #6e3440;
  --ok: #6fd39b;
  --focus: rgba(201, 162, 234, .6);
  --warn-bg: #3a3217; --warn-line: #6b5a1c; --warn-text: #f3d98a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
}
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }

/* ===== زر الوضع: شمس ⇄ قمر ===== */
.theme-toggle {
  appearance: none; position: relative; flex: none; width: 44px; height: 44px; padding: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow); transition: background .3s, border-color .2s, color .3s, transform .15s;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(.92) rotate(-12deg); }
.theme-toggle svg { width: 26px; height: 26px; overflow: visible; }
.theme-toggle .orb { transform-origin: 12px 12px; transition: transform .6s cubic-bezier(.4, 1.4, .5, 1); }
.theme-toggle .cut { transition: transform .6s cubic-bezier(.4, 1.4, .5, 1); }
.theme-toggle .rays { transform-origin: 12px 12px; transition: transform .6s cubic-bezier(.4, 1.4, .5, 1), opacity .3s; }
.theme-toggle .stars { opacity: 0; transform: scale(.3); transform-origin: 12px 12px; transition: opacity .4s .15s, transform .5s .15s; }
html[data-theme="dark"] .theme-toggle { color: #f4dcff; }
html[data-theme="dark"] .theme-toggle .orb { transform: scale(1.45) rotate(-25deg); }
html[data-theme="dark"] .theme-toggle .cut { transform: translate(-7px, 7px); }
html[data-theme="dark"] .theme-toggle .rays { transform: rotate(90deg) scale(.3); opacity: 0; }
html[data-theme="dark"] .theme-toggle .stars { opacity: 1; transform: none; }
html[data-theme="dark"] .theme-toggle .stars circle { animation: gz-twinkle 2.6s ease-in-out infinite; }
html[data-theme="dark"] .theme-toggle .stars circle:nth-child(2) { animation-delay: .9s; }
html[data-theme="dark"] .theme-toggle .stars circle:nth-child(3) { animation-delay: 1.7s; }
@keyframes gz-twinkle { 50% { opacity: .25; } }

/* كشف دائري عند التبديل (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
