/* صفحة الدخول: بوابتين في نظام واحد.
   بوابة الطلبة بألوان المتجر (كحلي ودهبي)، وبوابة الموظفين بألوان لوحة الإدارة (بنفسجي)،
   علشان كل واحد يعرف هو داخل على أنهي وش من النظام. الوضع الليلي من _ThemeBoot (data-theme). */
:root {
  --bg: #f3f5fa;
  --bg-glow: rgba(79, 70, 229, .08);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --ink: #121a2e;
  --ink-2: #3c4760;
  --muted: #67718a;
  --line: #e2e7f0;
  --shadow: 0 24px 60px -28px rgba(18, 26, 46, .28);

  --stu: #1d3461;          /* نص وأيقونة بوابة الطلبة */
  --stu-solid: #1d3461;    /* خلفية الزرار (الكلام عليه أبيض) */
  --stu-solid-2: #2a4a85;
  --stu-soft: #e8edf7;
  --stu-gold: #c9861a;

  --stf: #4338ca;
  --stf-solid: #4f46e5;
  --stf-solid-2: #6366f1;
  --stf-soft: #eef2ff;

  --info-soft: #eef4ff;
  --info-ink: #1e3a8a;
  --danger-soft: #fdeeee;
  --danger-ink: #b42318;
  --warn-soft: #fff6dd;
  --warn-ink: #8a5a0c;

  --f-display: "Cairo", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Cairo", Tahoma, "Segoe UI", sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-glow: rgba(99, 102, 241, .14);
  --surface: #111a2e;
  --surface-2: #0e1627;
  --ink: #e5eaf5;
  --ink-2: #c3cbe0;
  --muted: #8b97b3;
  --line: #24314f;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, .7);

  --stu: #a9c1f0;
  --stu-solid: #2a4a85;
  --stu-solid-2: #3a5fa3;
  --stu-soft: rgba(42, 74, 133, .28);
  --stu-gold: #e0a23b;

  --stf: #a5b4fc;
  --stf-solid: #5850ec;
  --stf-solid-2: #6d6af7;
  --stf-soft: rgba(99, 102, 241, .18);

  --info-soft: rgba(59, 130, 246, .14);
  --info-ink: #bfdbfe;
  --danger-soft: rgba(239, 68, 68, .14);
  --danger-ink: #fca5a5;
  --warn-soft: rgba(245, 158, 11, .14);
  --warn-ink: #fcd34d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html.theme-switching * { transition: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1100px 520px at 85% -10%, var(--bg-glow), transparent 70%), var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15.5px;
  line-height: 1.7;
}
a { color: inherit; }
.when-dark { display: none; }
[data-theme="dark"] .when-dark { display: inline; }
[data-theme="dark"] .when-light { display: none; }

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1080px;
  margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 22px 8px; }
.auth-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.auth-brand b { display: block; font-family: var(--f-display); font-size: 1.12rem; line-height: 1.3; }
.auth-brand small { display: block; color: var(--muted); font-size: .76rem; }
.auth-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-size: 1.25rem; background: linear-gradient(135deg, #1d3461, #4f46e5); box-shadow: 0 10px 24px -10px rgba(79, 70, 229, .8); }
.auth-theme { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 1.05rem; cursor: pointer; }
.auth-theme:hover { border-color: var(--muted); }
.auth-theme:focus-visible, .portal-btn:focus-visible, .dev-card :focus-visible { outline: 3px solid var(--stf-solid-2); outline-offset: 2px; }

.auth-main { flex: 1; display: flex; flex-direction: column; gap: 22px; padding-block: 18px 32px; }

.auth-intro { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 8px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--stf); background: var(--stf-soft); border-radius: 99px; padding: 4px 12px; }
.auth-intro h1 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: clamp(1.7rem, 4.2vw, 2.5rem); line-height: 1.3; text-wrap: balance; }
.auth-intro p { margin: 0; color: var(--muted); max-width: 56ch; text-wrap: balance; }

.auth-alert { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 13px 16px; font-size: .92rem; max-width: 760px; margin-inline: auto; width: 100%; }
.auth-alert > i { font-size: 1.2rem; line-height: 1.5; }
.auth-alert b { display: block; }
.auth-alert b.d-inline { display: inline; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.auth-panel { width: 100%; max-width: 560px; margin-inline: auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 30px 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-panel .portal-icon { --c-solid: var(--stf-solid); --c-solid-2: var(--stf-solid-2); }
.auth-panel h1 { margin: 6px 0 0; font-family: var(--f-display); font-size: 1.35rem; }
.auth-panel p { margin: 0; color: var(--muted); }
.auth-alert.danger { background: var(--danger-soft); color: var(--danger-ink); }
.auth-alert.info { background: var(--info-soft); color: var(--info-ink); }

/* البوابتين */
.portals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.portal {
  --c: var(--stu); --c-solid: var(--stu-solid); --c-solid-2: var(--stu-solid-2); --c-soft: var(--stu-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.portal.staff { --c: var(--stf); --c-solid: var(--stf-solid); --c-solid-2: var(--stf-solid-2); --c-soft: var(--stf-soft); }
.portal::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 5px; background: linear-gradient(90deg, var(--c-solid), var(--c-solid-2)); }
.portal.student::before { background: linear-gradient(90deg, var(--stu-solid), var(--stu-gold)); }
.portal.suggested { border-color: var(--c-solid-2); box-shadow: 0 0 0 4px var(--c-soft), var(--shadow); }

.portal-head { display: flex; align-items: center; gap: 14px; }
.portal-icon { width: 56px; height: 56px; flex: none; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: linear-gradient(135deg, var(--c-solid), var(--c-solid-2)); }
.portal.student .portal-icon { background: linear-gradient(135deg, var(--stu-solid), #33589a); }
.portal-tag { display: inline-block; font-size: .74rem; font-weight: 600; color: var(--c); background: var(--c-soft); border-radius: 99px; padding: 1px 10px; }
.portal h2, .dev-card h2 { margin: 4px 0 0; font-family: var(--f-display); font-weight: 800; font-size: 1.45rem; line-height: 1.3; }
.portal-sub { margin: 0; color: var(--muted); font-size: .9rem; }
.portal-flag { margin-inline-start: auto; align-self: flex-start; font-size: .74rem; font-weight: 700; color: var(--c); border: 1px solid var(--c-solid-2); border-radius: 99px; padding: 2px 10px; white-space: nowrap; }

.portal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; flex: 1; }
.portal-list li { display: flex; align-items: flex-start; gap: 10px; color: var(--ink-2); font-size: .94rem; }
.portal-list i { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--c); background: var(--c-soft); font-size: .95rem; }
.portal-list span { padding-top: 3px; }

.portal-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; border-radius: 14px; border: 0;
  font-family: var(--f-display); font-weight: 700; font-size: 1.05rem;
  color: #fff; text-decoration: none; cursor: pointer;
  background: linear-gradient(135deg, var(--c-solid), var(--c-solid-2));
  box-shadow: 0 12px 26px -14px var(--c-solid);
  transition: transform .15s, box-shadow .15s;
}
.portal-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -14px var(--c-solid); }
.portal-note { margin: -6px 0 0; text-align: center; color: var(--muted); font-size: .8rem; }

/* نظام واحد بدل نظامين */
.merge { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.merge-title { font-family: var(--f-display); font-weight: 700; font-size: 1rem; text-align: center; }
.merge-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1.25fr; align-items: stretch; gap: 10px; }
.merge-item { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; border-radius: 14px; padding: 12px 10px; border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.merge-item i { font-size: 1.25rem; color: var(--muted); }
.merge-item b { font-size: .9rem; line-height: 1.4; }
.merge-item small { font-size: .74rem; color: var(--muted); }
.merge-item.old b { color: var(--ink-2); }
.merge-item.old small { text-decoration: line-through; text-decoration-color: var(--muted); }
.merge-item.new { border-color: var(--stf-solid-2); background: var(--stf-soft); }
.merge-item.new i, .merge-item.new b { color: var(--stf); }
.merge-op { display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 1.1rem; }

.dev-note { margin: 0; text-align: center; font-size: .82rem; color: var(--warn-ink); }
.dev-note span { background: var(--warn-soft); border-radius: 14px; padding: 5px 14px; display: inline-flex; gap: 6px; align-items: center; }

.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; padding-block: 8px 24px; }

/* الدخول التجريبي */
.dev-card {
  --c: var(--stu); --c-solid: var(--stu-solid); --c-solid-2: var(--stu-solid-2); --c-soft: var(--stu-soft);
  width: 100%; max-width: 520px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 24px 26px 26px; display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden;
}
.dev-card.staff { --c: var(--stf); --c-solid: var(--stf-solid); --c-solid-2: var(--stf-solid-2); --c-soft: var(--stf-soft); }
.dev-card::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 5px; background: linear-gradient(90deg, var(--c-solid), var(--c-solid-2)); }
.dev-back { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); text-decoration: none; align-self: flex-start; }
.dev-back:hover { color: var(--ink); }
.dev-warn { margin: 0; font-size: .84rem; color: var(--warn-ink); background: var(--warn-soft); border-radius: 12px; padding: 10px 14px; }
.dev-card form { display: flex; flex-direction: column; gap: 14px; }
.dev-field { display: flex; flex-direction: column; gap: 6px; }
.dev-field label, .dev-legend { font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.dev-field input, .dev-field select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  min-height: 46px; padding: 8px 14px; width: 100%;
}
.dev-field input:focus, .dev-field select:focus { outline: none; border-color: var(--c-solid-2); box-shadow: 0 0 0 4px var(--c-soft); }
.dev-hint { color: var(--muted); font-size: .78rem; }

/* الدخول التجريبي للموظفين: «أو» وزرار الدخول كمدير تجريبي */
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.alt-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; }
.alt-btn:hover { border-color: var(--c-solid-2); }
.dev-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0; }
.dev-choice { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; background: var(--surface-2); }
.dev-choice:has(input:checked) { border-color: var(--c-solid-2); background: var(--c-soft); }
.dev-choice input { accent-color: var(--c-solid); margin-top: 5px; }
.dev-choice b { display: block; font-size: .92rem; }
.dev-choice small { color: var(--muted); font-size: .78rem; }

@media (max-width: 860px) {
  .portals { grid-template-columns: 1fr; }
  .merge-flow { grid-template-columns: 1fr; }
  .merge-op i { display: inline-block; transform: rotate(-90deg); } /* السهم لتحت لما العناصر تبقى فوق بعض */
}
@media (max-width: 480px) {
  .portal { padding: 22px 18px 18px; }
  .dev-card { padding: 22px 18px; }
  .dev-choices { grid-template-columns: 1fr; }
  .portal-flag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-btn { transition: none; }
}

/* English / عربي في صفحات الدخول. */
.auth-tools { display: flex; align-items: center; gap: 8px; }
.auth-lang { display: inline-grid; place-items: center; font-family: inherit; font-size: .8rem; font-weight: 800; text-decoration: none; }
html[dir="ltr"] .bi[class*="-left"]:not([class*="left-right"]),
html[dir="ltr"] .bi[class*="-right"]:not([class*="left-right"]) { display: inline-block; transform: scaleX(-1); }
