/* ===== صفحة تسجيل الدخول — تصميم عصري بألوان هوية النظام (بتتغير تلقائياً من الإعدادات) ===== */

body.login-page {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: block;
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(180deg, #ffffff 0%, var(--primary-tint, #eef2fb) 100%);
  font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink, #1b2233);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- الخلفية ---------- */
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-blob { position: absolute; border-radius: 50%; filter: blur(2px); }
.bg-blob-a {
  width: 420px; height: 420px; top: -190px; left: -150px;
  background: radial-gradient(circle at 40% 40%, var(--primary, #2b4cc4), transparent 70%);
  opacity: .16;
}
.bg-blob-b {
  width: 300px; height: 300px; top: 22%; right: -140px;
  background: radial-gradient(circle at 50% 50%, var(--primary, #2b4cc4), transparent 70%);
  opacity: .08;
}
.bg-waves {
  position: absolute; left: 0; right: 0; bottom: 0;
  width: 100%; height: clamp(120px, 24vh, 240px);
}
.bg-waves .wave { fill: var(--primary, #2b4cc4); }
.bg-waves .w1 { opacity: .07; }
.bg-waves .w2 { opacity: .12; }
.bg-waves .w3 { opacity: .22; }

/* ---------- الهيكل ---------- */
.login-shell {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.login-card {
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;
  padding: 30px 34px 24px;
  text-align: center;
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 30px;
  box-shadow: 0 30px 70px rgba(16, 28, 77, .13), 0 2px 10px rgba(16, 28, 77, .05);
  animation: card-in .55s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- الرسمة العلوية ---------- */
.login-hero {
  position: relative;
  width: min(250px, 66%);
  margin: 0 auto 6px;
  aspect-ratio: 260 / 230;
}
.hero-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hero-mark {
  position: absolute; left: 50%; top: 51.4%;
  transform: translate(-50%, -50%);
  width: 58px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  overflow: hidden;
}
.hero-dots { width: 54px; height: auto; display: block; }
.hero-dots circle { fill: var(--primary, #2b4cc4); }
.hero-dots circle:nth-child(1) { animation: dot-pulse 1.8s ease-in-out infinite; }
.hero-dots circle:nth-child(2) { animation: dot-pulse 1.8s ease-in-out .25s infinite; }
.hero-dots circle:nth-child(3) { animation: dot-pulse 1.8s ease-in-out .5s infinite; }
@keyframes dot-pulse {
  0%, 60%, 100% { opacity: 1; }
  30% { opacity: .35; }
}

/* ---------- العناوين ---------- */
.login-card h1 {
  margin: 8px 0 6px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--primary-dark, #14234f);
}
.login-brand { color: var(--primary, #2b4cc4); }
.login-sub {
  margin: 0 0 24px;
  font-size: 14.5px;
  color: var(--ink-muted, #6b7488);
}

/* ---------- الحقول ---------- */
.login-field {
  position: relative;
  margin: 0 0 14px;
  text-align: right;
}
.login-field input {
  width: 100%;
  height: 56px;
  box-sizing: border-box;
  padding: 0 52px 0 50px;
  border: 1.5px solid #e2e7f1;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(16, 28, 77, .05);
  font-family: inherit;
  font-size: 16px; /* 16px عشان آيفون ما يعملش zoom */
  color: var(--ink, #1b2233);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.login-field input::placeholder { color: #8d96aa; opacity: 1; }
.login-field input:hover { border-color: #cdd5e6; }
.login-field input:focus {
  border-color: var(--primary, #2b4cc4);
  box-shadow: 0 0 0 4px var(--primary-tint, #e6ebfa), 0 4px 14px rgba(16, 28, 77, .06);
}
.login-field input:-webkit-autofill,
.login-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 40px #fff inset;
  -webkit-text-fill-color: var(--ink, #1b2233);
}
.login-field.invalid input { border-color: var(--warn, #b4492b); }

.field-icon {
  position: absolute; top: 50%; right: 18px;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  color: #7e88a0;
  pointer-events: none;
  transition: color .15s ease;
}
.login-field:focus-within .field-icon { color: var(--primary, #2b4cc4); }
.field-icon svg, .field-toggle svg, .submit-arrow svg, .login-secure svg {
  width: 100%; height: 100%; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.field-toggle {
  position: absolute; top: 50%; left: 8px;
  transform: translateY(-50%);
  width: 40px; height: 40px; padding: 9px;
  box-sizing: border-box;
  border: none; border-radius: 12px;
  background: transparent;
  color: #7e88a0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.field-toggle:hover { background: var(--primary-tint, #e6ebfa); color: var(--primary, #2b4cc4); }
.field-toggle:focus-visible { outline: 2px solid var(--primary, #2b4cc4); outline-offset: 1px; }
.field-toggle .eye-off { display: none; }
.field-toggle[aria-pressed="true"] .eye-on { display: none; }
.field-toggle[aria-pressed="true"] .eye-off { display: block; }

/* ---------- نسيت كلمة السر ---------- */
.login-aux { text-align: right; margin: -2px 0 6px; }
.login-forgot {
  border: none; background: none; padding: 6px 2px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--primary, #2b4cc4);
  cursor: pointer;
}
.login-forgot:hover { text-decoration: underline; text-underline-offset: 3px; }
.login-forgot:focus-visible { outline: 2px solid var(--primary, #2b4cc4); outline-offset: 2px; border-radius: 6px; }
.login-note {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--primary-tint, #e6ebfa);
  color: var(--primary-dark, #14234f);
  font-size: 13.5px; line-height: 1.6;
  text-align: right;
}
.login-note[hidden], .login-error[hidden] { display: none; }

/* ---------- الخطأ ---------- */
.login-error {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 14px;
  background: #fbe9e3;
  border: 1px solid #f1cfc4;
  color: var(--warn, #b4492b);
  font-size: 13.5px; font-weight: 700; line-height: 1.6;
  text-align: right;
}
.login-card.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ---------- الزرار ---------- */
.login-submit {
  position: relative;
  width: 100%;
  height: 58px;
  margin-top: 8px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary-dark, #14234f) 0%, var(--primary, #2b4cc4) 100%);
  color: #fff;
  font-family: inherit; font-size: 17px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 28px color-mix(in srgb, var(--primary, #2b4cc4) 38%, transparent);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  overflow: hidden;
}
.login-submit:hover { filter: brightness(1.06); box-shadow: 0 18px 34px color-mix(in srgb, var(--primary, #2b4cc4) 46%, transparent); }
.login-submit:active { transform: scale(.985); }
.login-submit:focus-visible { outline: 3px solid var(--primary-tint, #e6ebfa); outline-offset: 2px; }
.submit-arrow {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 38px; height: 38px; padding: 9px; box-sizing: border-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  transition: transform .2s ease, background .2s ease;
}
.login-submit:hover .submit-arrow { transform: translateY(-50%) translateX(-3px); background: rgba(255, 255, 255, .28); }
.submit-spinner {
  display: none;
  width: 22px; height: 22px;
  margin-inline-start: 10px;
  border: 3px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-submit.loading { cursor: wait; filter: none; }
.login-submit.loading .submit-spinner { display: inline-block; }
.login-submit.loading .submit-arrow { display: none; }
.login-submit:disabled { opacity: .85; }

/* ---------- سطر الأمان ---------- */
.login-secure {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 18px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint, #8a93a6);
}
.login-secure svg { width: 15px; height: 15px; }

/* ---------- الجوال: شاشة كاملة بدون كرت (مثل التطبيقات) ---------- */
@media (max-width: 520px) {
  .login-shell { align-items: flex-start; padding: max(18px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom)); }
  .login-card {
    max-width: none;
    padding: 6px 0 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .login-hero { width: min(240px, 62%); margin-top: 4px; }
  .login-card h1 { font-size: 23px; }
  .login-sub { margin-bottom: 22px; }
}
@media (max-height: 640px) and (max-width: 520px) {
  .login-hero { width: min(170px, 46%); }
  .login-sub { margin-bottom: 14px; }
}

/* ---------- تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
  .login-card, .hero-dots circle, .login-card.shake { animation: none !important; }
  .login-submit, .submit-arrow, .login-field input { transition: none; }
}
