/* ============================================================
   EduCreate — Auth pages (Login / AccessDenied / future)
   يعتمد كلياً على توكنات colors_and_type.css — لا ألوان ثابتة.

   توزيع الألوان مضبوط على نسب دليل الهوية:
     الأزرق 40% · الفيروزي 30% · الذهبي 10% · الداكن 15% · الأبيض 5%
   الأبيض يبقى أعلى من 5% لأن بطاقة النموذج يجب أن تظل بيضاء
   لضمان تباين النص والحقول (WCAG) — بقية النسب مضبوطة عليها.
   ============================================================ */

/* ---------- الهيكل العام ---------- */
.ec-auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--ec-blue-800);
}

.ec-auth-wrap {
  display: grid;
  grid-template-columns: 1.24fr 1fr;
  min-height: 0;
}

/* ============================================================
   1. لوحة الهوية — حاملة الأزرق (40%) والفيروزي
   ============================================================ */
.ec-auth-brand {
  position: relative;
  overflow: hidden;
  /* تدرّج بنسبة ~60% أزرق مقابل ~40% فيروزي داخل اللوحة */
  background: linear-gradient(155deg,
              var(--ec-blue-800) 0%,
              var(--ec-blue-600) 34%,
              var(--ec-blue-500) 54%,
              var(--ec-sky-600) 78%,
              var(--ec-sky-500) 100%);
  color: var(--ec-white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-7);
}

/* الخط الذهبي العلوي — per brand guide */
.ec-auth-brand::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--grad-gold-line);
  z-index: 3;
}

.ec-auth-brand > *:not(.ec-auth-deco) {
  position: relative;
  z-index: 2;
}

/* شبكة الأيقونات الزخرفية */
.ec-auth-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-5);
  opacity: 0.13;
  pointer-events: none;
}

.ec-auth-pattern svg {
  width: 100%;
  height: 100%;
}

/* عمق داكن أسفل اللوحة — يحمل جزءاً من حصة الرمادي الداكن (15%) */
.ec-auth-shade {
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  z-index: 1;
  background: linear-gradient(to top,
              color-mix(in srgb, var(--ec-ink-900) 72%, transparent) 0%,
              transparent 100%);
  pointer-events: none;
}

/* شارة ذهبية — تعتمد .ec-badge.gold من نظام التصميم */
.ec-auth-brand .ec-badge {
  width: fit-content;
  font-family: var(--font-arabic);
  padding: 8px 18px;
  box-shadow: var(--shadow-gold);
}

/* الشعار */
.ec-auth-logo {
  background: var(--ec-white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  border-bottom: 4px solid var(--ec-gold-500);
  padding: var(--sp-4) var(--sp-5);
  width: fit-content;
  max-width: 290px;
}

.ec-auth-logo img {
  display: block;
  width: 100%;
  max-width: 214px;
  height: auto;
}

.ec-auth-brand h2 {
  font-family: var(--font-arabic);
  font-size: 30px;
  font-weight: var(--fw-extrabold);
  line-height: 1.45;
  letter-spacing: 0;
  max-width: 20ch;
  margin: 0;
}

/* شريط ذهبي تحت العنوان — نفس موتيف .ec-sec-title */
.ec-auth-brand h2::after {
  content: "";
  display: block;
  width: 88px;
  height: 6px;
  margin-top: var(--sp-4);
  border-radius: 3px;
  background: var(--ec-gold-500);
}

.ec-auth-brand .ec-auth-lede {
  font-family: var(--font-arabic);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-loose);
  color: color-mix(in srgb, var(--ec-white) 84%, transparent);
  max-width: 34ch;
  margin: 0;
}

/* نقاط الثقة — لوحة ذهبية مصمتة، هي حاملة حصة الذهبي (10%) */
.ec-auth-points {
  list-style: none;
  margin: var(--sp-2) 0 0;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  max-width: 440px;
  background: var(--ec-gold-500);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-gold);
}

.ec-auth-point {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-arabic);
  font-size: 14.5px;
  font-weight: var(--fw-bold);
  /* تباين 6.2:1 على الذهبي — يتجاوز AA */
  color: var(--ec-blue-900);
}

.ec-auth-point i {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--ec-white);
  color: var(--ec-blue-600);
}

.ec-auth-point i svg {
  width: 19px;
  height: 19px;
}

/* ============================================================
   2. جانب النموذج — حامل الفيروزي (30%)
   ============================================================ */
.ec-auth-form-side {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7) var(--sp-5);
  /* خلفية فيروزية صريحة بدل الكانفاس المحايد */
  background: linear-gradient(200deg, var(--ec-sky-300) 0%, var(--ec-sky-400) 100%);
}

.ec-auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  background: var(--bg-paper);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  border-top: 5px solid var(--ec-gold-500);
  padding: 36px;
}

.ec-auth-card h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-arabic);
  font-size: 26px;
  font-weight: var(--fw-extrabold);
  line-height: var(--lh-snug);
  letter-spacing: 0;
  color: var(--ec-ink-900);
  margin: 0 0 6px;
}

.ec-auth-card h1::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 26px;
  border-radius: 3px;
  background: var(--ec-gold-500);
}

.ec-auth-card .sub {
  font-size: var(--fs-body-sm);
  color: var(--fg-2);
  margin: 0 0 var(--sp-5);
}

/* ---------- شريط الخطأ ---------- */
.ec-auth-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  background: color-mix(in srgb, var(--ec-danger) 8%, var(--bg-paper));
  border: 1px solid color-mix(in srgb, var(--ec-danger) 26%, transparent);
  border-inline-start: 3px solid var(--ec-danger);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 0 0 var(--sp-5);
  font-size: 13.5px;
  line-height: var(--lh-normal);
  color: var(--ec-ink-800);
  animation: ec-auth-slide var(--dur-base) var(--ease-emphasized) both;
}

/* نسخة النجاح — تُستخدم في صفحتَي تأكيد استعادة كلمة المرور */
.ec-auth-alert.is-success {
  background: color-mix(in srgb, var(--ec-success) 8%, var(--bg-paper));
  border-color: color-mix(in srgb, var(--ec-success) 26%, transparent);
  border-inline-start-color: var(--ec-success-text);
}

.ec-auth-alert.is-success i { color: var(--ec-success-text); }

.ec-auth-alert i {
  flex: 0 0 auto;
  color: var(--ec-danger);
  display: inline-flex;
  margin-top: 1px;
}

.ec-auth-alert i svg {
  width: 18px;
  height: 18px;
}

@keyframes ec-auth-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- الحقول ---------- */
.ec-auth-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.ec-auth-field label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: var(--fw-bold);
  color: var(--ec-ink-900);
}

.ec-auth-ctrl {
  position: relative;
}

.ec-auth-field input[type="email"],
.ec-auth-field input[type="text"],
.ec-auth-field input[type="password"] {
  font: inherit;
  font-size: 15px;
  width: 100%;
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 13px 15px;
  background: var(--bg-paper);
  color: var(--fg-1);
  outline: none;
  /* حقول لاتينية داخل صفحة RTL — عرف قائم في المشروع */
  direction: ltr;
  text-align: right;
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}

/* مساحة أيقونة الحقل على اليمين (النص محاذى يميناً فالـ padding يزيحه) */
.ec-auth-field .ec-auth-ctrl input[type="email"],
.ec-auth-field .ec-auth-ctrl input[type="text"],
.ec-auth-field .ec-auth-ctrl input[type="password"] {
  padding-right: 44px;
}

/* مساحة زر العين على اليسار (الحقل نفسه direction: ltr) */
.ec-auth-field .ec-auth-ctrl.has-eye input[type="password"],
.ec-auth-field .ec-auth-ctrl.has-eye input[type="text"] {
  padding-left: 48px;
}

.ec-auth-field input::placeholder {
  color: var(--fg-3);
}

.ec-auth-field input:focus {
  border-color: var(--ec-sky-500);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ec-sky-500) 20%, transparent);
}

/* حالة الخطأ — jquery-validation تضيف input-validation-error */
.ec-auth-field input.input-validation-error {
  border-color: var(--ec-danger);
}

.ec-auth-field input.input-validation-error:focus {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ec-danger) 18%, transparent);
}

.ec-auth-field .field-error {
  color: var(--ec-danger-text);  /* raw danger on white was 3.76:1, fails at 12.5px; danger-text passes at 5.74:1 */
  font-size: 12.5px;
  line-height: var(--lh-snug);
}

.ec-auth-field .field-error:empty {
  display: none;
}

/* أيقونة داخل الحقل */
.ec-auth-ico {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--fg-3);
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease-standard);
}

.ec-auth-ico svg {
  width: 18px;
  height: 18px;
}

/* الأيقونة تلي الحقل في الـ DOM ليعمل ~ */
.ec-auth-ctrl input:focus ~ .ec-auth-ico {
  color: var(--ec-blue-600);
}

/* أيقونة صغيرة بجانب اسم الحقل */
.ec-auth-field label i {
  display: inline-flex;
  color: var(--ec-sky-600);
}

.ec-auth-field label i svg {
  width: 15px;
  height: 15px;
}

/* ---------- زر العين ---------- */
.ec-auth-eye {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}

.ec-auth-eye:hover {
  color: var(--ec-blue-600);
  background: var(--ec-blue-050);
}

.ec-auth-eye:focus-visible {
  outline: none;
  color: var(--ec-blue-600);
  background: var(--ec-blue-050);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ec-sky-500) 30%, transparent);
}

.ec-auth-eye svg {
  width: 19px;
  height: 19px;
}

.ec-auth-eye .icon-off { display: none; }
.ec-auth-eye[aria-pressed="true"] .icon-on { display: none; }
.ec-auth-eye[aria-pressed="true"] .icon-off { display: inline-flex; }

/* ---------- صف تذكرني ---------- */
.ec-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-2) 0 var(--sp-5);
}

.ec-auth-remember {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13.5px;
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
}

.ec-auth-remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--ec-blue-600);
  cursor: pointer;
  margin: 0;
}

.ec-auth-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--fg-3);
}

.ec-auth-note i { display: inline-flex; color: var(--ec-gold-600); }
.ec-auth-note i svg { width: 14px; height: 14px; }

/* ---------- الزر ---------- */
.ec-auth-submit {
  width: 100%;
  justify-content: center;
}

.ec-auth-submit svg { width: 18px; height: 18px; }

/* السهم يشير لجهة القراءة في RTL */
[dir="rtl"] .ec-auth-submit svg { transform: scaleX(-1); }

/* ---------- تذييل البطاقة ---------- */
.ec-auth-foot {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-1);
  font-size: 12.5px;
  color: var(--fg-3);
  text-align: center;
  line-height: var(--lh-loose);
}

.ec-auth-foot a {
  color: var(--ec-blue-700);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.ec-auth-foot a:hover,
.ec-auth-foot a:focus-visible { color: var(--ec-ink-900); }

/* ============================================================
   3. التذييل الداكن — حامل الرمادي الداكن (15%)
   ============================================================ */
.ec-auth-footer {
  background: var(--ec-ink-900);
  border-top: 4px solid var(--ec-gold-500);
  color: color-mix(in srgb, var(--ec-white) 72%, transparent);
  padding: 34px var(--sp-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: 13px;
}

.ec-auth-footer .ec-wordmark {
  font-size: 19px;
  color: var(--ec-white);
}

.ec-auth-footer .ec-wordmark em { color: var(--ec-sky-500); }

.ec-auth-footer-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.ec-auth-footer-meta i { display: inline-flex; color: var(--ec-gold-500); }
.ec-auth-footer-meta i svg { width: 15px; height: 15px; }

/* ============================================================
   الاستجابة
   ============================================================ */
@media (max-width: 900px) {
  .ec-auth-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .ec-auth-brand {
    min-height: auto;
    padding: var(--sp-5) var(--sp-5) var(--sp-6);
    gap: var(--sp-4);
    align-items: center;
    text-align: center;
  }

  .ec-auth-pattern,
  .ec-auth-shade,
  .ec-auth-points {
    display: none;
  }

  .ec-auth-logo {
    max-width: 230px;
    padding: var(--sp-3) var(--sp-4);
  }

  .ec-auth-logo img {
    max-width: 168px;
  }

  .ec-auth-brand h2 {
    font-size: 21px;
    max-width: 28ch;
  }

  .ec-auth-brand h2::after {
    margin-inline: auto;
    margin-top: var(--sp-3);
    width: 64px;
    height: 5px;
  }

  .ec-auth-brand .ec-auth-lede {
    display: none;
  }

  .ec-auth-form-side {
    padding: var(--sp-6) var(--sp-4) var(--sp-7);
    align-items: flex-start;
  }

  .ec-auth-footer {
    justify-content: center;
    text-align: center;
    padding: var(--sp-4);
    gap: 6px var(--sp-4);
    font-size: 12px;
  }

  .ec-auth-footer .ec-wordmark {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .ec-auth-card {
    padding: 26px 20px;
    border-radius: var(--r-lg);
  }

  .ec-auth-card h1 {
    font-size: 23px;
  }

  /* 16px يمنع تكبير iOS التلقائي عند التركيز */
  .ec-auth-field input[type="email"],
  .ec-auth-field input[type="text"],
  .ec-auth-field input[type="password"] {
    font-size: 16px;
  }

  .ec-auth-form-side {
    padding: var(--sp-5) var(--sp-4) var(--sp-6);
  }

  .ec-auth-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ec-auth-alert,
  .ec-auth-eye,
  .ec-auth-ico,
  .ec-auth-field input {
    animation: none !important;
    transition: none !important;
  }
}
