/* ==========================================================================
   منصة إحقاق — تصميم شاشات الدخول (مطابق لـ portal-auth)
   يُحمَّل بعد style.bundle.css ويعيد تلوين عناصر Metronic داخل .auth فقط.
   ثلاث سمات: دائن (تركوازي) / إداري وأمين (أخضر) / مدين (برونزي)
   ========================================================================== */

.auth {
  --paper:  #FFFFFF;
  --field:  #EFF3F4;
  --ink:    #0C1F24;
  --ink-2:  #3A5459;
  --ink-3:  #4C6A70;
  --muted:  #7E959B;
  --line:   rgba(12, 31, 36, 0.14);
  --radius: 10px;

  --f-display: 'Readex Pro', 'Segoe UI', Tahoma, sans-serif;
  --f-body:    'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --f-mono:    'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

  /* دائن (الافتراضي) */
  --role: #176E77; --role-dark: #0F5259; --role-tint: #E9F3F4;
  --role-soft: rgba(33, 145, 156, .10);

  /* ربط ألوان Metronic بلون الدور */
  --kt-primary: var(--role);
  --kt-primary-active: var(--role-dark);
  --kt-primary-light: var(--role-tint);
  --kt-primary-inverse: #fff;
  --kt-input-bg: var(--field);
  --kt-input-color: var(--ink);
  --kt-input-border-color: transparent;
  --kt-input-focus-bg: #fff;
  --kt-input-focus-color: var(--ink);
  --kt-input-focus-border-color: var(--role);
  --kt-input-placeholder-color: #93A8AD;
  --kt-form-check-input-checked-bg-color: var(--role);
  --kt-form-check-input-checked-border-color: var(--role);

  min-height: 100vh; min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
}

.auth--admin {
  --role: #1C6B4F; --role-dark: #134E38; --role-tint: #E8F2ED;
  --role-soft: rgba(36, 138, 102, .10);
}
.auth--debtor {
  --role: #8A6D28; --role-dark: #65551E; --role-tint: #F6F1E3;
  --role-soft: rgba(138, 109, 40, .10);
}

.auth ::selection { background: var(--role); color: #fff; }
.auth :where(a, button, input, select):focus-visible { outline: 2px solid var(--role); outline-offset: 3px; }

/* ------------------------------------------------------- brand panel --- */

.auth__brand {
  position: relative;
  background: var(--role);
  color: #fff;
}

/* يبقى مرئيًا أثناء التمرير في النماذج الطويلة */
.auth__brandin {
  position: sticky; top: 0; overflow: hidden;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 48px 48px 88px;
}

/* الزخرفة الهندسية — علامة إحقاق بدون الكلمات */
.auth__brandin::before {
  content: ""; position: absolute; bottom: -110px; inset-inline-start: -80px;
  width: min(600px, 120%); height: 557px;
  pointer-events: none; opacity: .18;
  background: url("../../images/auth/brand-circuit.png") no-repeat bottom right / contain;
}
.auth__brandin:dir(ltr)::before { background-position: bottom left; transform: scaleX(-1); }
.auth__brandin > * { position: relative; z-index: 1; }

.auth__logo { display: flex; justify-content: center; width: 100%; line-height: 0; }
.auth__logo img { width: 400px; max-width: 100%; height: auto; filter: brightness(0) invert(1); }

.auth__brandcol {
  width: 100%; max-width: 360px; margin-top: 40px;
  display: flex; flex-direction: column; align-items: center;
}

.auth__client { display: flex; align-items: center; justify-content: center; gap: 16px; text-align: start; }
.auth__clientlogo {
  flex: none; width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px; overflow: hidden; background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
}
.auth__clientlogo img { width: 100%; height: 100%; object-fit: contain; }
/* شعار أفقي يحمل اسم الشركة (مثل يوناسكو) — بطاقة بيضاء عريضة بدل المربّع */
.auth__clientlogo--wide { width: auto; height: auto; padding: 14px 20px; border-radius: 14px; }
.auth__clientlogo--wide img { width: 220px; max-width: 100%; height: auto; }
.auth__miniclient img.wide { width: auto; height: 34px; padding: 3px 6px; background: #fff; border-radius: 8px; object-fit: contain; }
.auth__clientname {
  font-size: 17px; font-weight: 700; line-height: 1.55; color: #fff; unicode-bidi: isolate;
}
.auth__clientname span {
  display: block; margin-top: 2px;
  font-size: 12.5px; font-weight: 500; line-height: 1.5; letter-spacing: .06em;
  text-transform: uppercase; color: rgba(255, 255, 255, .84); unicode-bidi: isolate;
}

.auth__hero {
  margin-top: 40px; padding-top: 24px; width: 100%;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: flex; flex-direction: column; align-items: center;
}
.auth__herotitle {
  margin: 0; font-family: var(--f-display);
  font-size: clamp(36px, 3.4vw, 50px); font-weight: 700; line-height: 1.3;
  color: #fff; text-wrap: balance;
}
.auth__herolead {
  margin: 12px auto 0; max-width: 32ch;
  font-size: 15px; line-height: 1.9; color: rgba(255, 255, 255, .92);
}

.auth__herosupport { margin: 20px 0 0; font-size: 13px; line-height: 1.8; color: rgba(255, 255, 255, .82); }
.auth__herosupport a { color: #fff; font-weight: 600; unicode-bidi: isolate; }

.auth__copy {
  position: absolute; bottom: 32px; inset-inline: 48px; margin: 0;
  font-size: 12px; line-height: 1.8; color: rgba(255, 255, 255, .82); text-align: center;
}
.auth__copy a { color: inherit; opacity: .55; margin-inline-start: 6px; }
.auth__copy a:hover { opacity: 1; }

/* ------------------------------------------------------------ layout --- */

.auth__form { position: relative; background: var(--paper); padding: 32px 24px; overflow-x: clip; }
.auth__form .w-lg-500px, .auth__form .w-lg-600px { max-width: 100%; }

@media (min-width: 992px) {
  .auth__brand { flex: 0 0 45%; max-width: 45%; }
  .auth__form  { flex: 1 1 55%; min-width: 0; }

  /* صفحات الشروط: محتوى عريض */
  .auth--wide .auth__brand { flex-basis: 32%; max-width: 32%; }
  .auth--wide .auth__herotitle { font-size: 34px; }
}

.auth__mini { display: none; }

/* ------------------------------------------------------ lang switch --- */

.auth__top { position: absolute; top: 24px; inset-inline-end: 24px; z-index: 5; }

.lang-switch {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-3); font-size: 13px; font-weight: 600; line-height: 1;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.lang-switch:hover { border-color: var(--role); color: var(--role); background: var(--role-soft); }
.lang-switch svg { opacity: .7; }

/* ------------------------------------------------------ form styling --- */

.auth__form h1, .auth__form h2, .auth__form .card-title {
  font-family: var(--f-display); font-weight: 700; color: var(--ink) !important;
  line-height: 1.35; text-wrap: balance;
}
.auth__form h1, .auth__form h2.card-title { font-size: 30px; }

.auth__form p, .auth__form .card-text,
.auth__form .text-gray-500, .auth__form .text-muted, .auth__form .text-gray-700 {
  color: var(--ink-2) !important; font-size: 14px; line-height: 1.8;
}

.auth__form .form-label, .auth__form label {
  font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--ink-2);
}

.auth__form .form-control,
.auth__form .form-select {
  min-height: 52px; padding: 12px 16px;
  background-color: var(--field);
  border: 1.5px solid transparent; border-radius: var(--radius);
  color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 400;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.auth__form .form-control.bg-transparent { background-color: var(--field) !important; }
.auth__form .form-control:hover,
.auth__form .form-select:hover { background-color: #E9F0F1 !important; }
.auth__form .form-control:focus,
.auth__form .form-select:focus {
  background-color: #fff !important; border-color: var(--role);
  box-shadow: 0 0 0 3px var(--role-soft) !important; outline: none;
}
.auth__form .form-control::placeholder { color: #93A8AD; }
.auth__form .input-group > .form-control { border-radius: var(--radius); }

/* القوائم المنسدلة — سهم portal-auth، الخيارات كما هي */
.auth__form .form-select {
  appearance: none; cursor: pointer;
  padding-inline: 16px 44px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%) !important;
  background-size: 6px 6px, 6px 6px !important;
  background-repeat: no-repeat !important;
}
.auth__form .form-select:dir(ltr) { background-position: calc(100% - 20px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px) !important; }
.auth__form .form-select:dir(rtl) { background-position: 20px calc(50% + 1px), 14px calc(50% + 1px) !important; }

/* حقل لم يجتز التحقق */
.auth__form .form-control.is-invalid,
.auth__form .form-select.is-invalid {
  border-color: #A32C2C !important; background-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(163, 44, 44, .10) !important;
}
.auth__form .form-control.is-invalid { background-image: none !important; }
.auth__form .form-check-input.is-invalid { border-color: #A32C2C !important; box-shadow: 0 0 0 3px rgba(163, 44, 44, .12); }

/* زر إظهار كلمة المرور — داخل الحقل عند نهايته */
.auth__form .form-password-toggle { position: relative; flex-wrap: nowrap; }
.auth__form .form-password-toggle > .form-control { width: 100%; padding-inline-end: 52px; border-radius: var(--radius) !important; }
.auth__form .form-password-toggle > .input-group-text,
.auth__form [data-kt-password-meter-control="visibility"] {
  position: absolute !important; top: 50% !important; z-index: 5;
  transform: translateY(-50%) !important; margin: 0 !important;
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 10px;
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.auth__form .form-password-toggle > .input-group-text:dir(rtl),
.auth__form [data-kt-password-meter-control="visibility"]:dir(rtl) { left: 6px !important; right: auto !important; }
.auth__form .form-password-toggle > .input-group-text:dir(ltr),
.auth__form [data-kt-password-meter-control="visibility"]:dir(ltr) { right: 6px !important; left: auto !important; }
.auth__form .form-password-toggle > .input-group-text:hover,
.auth__form [data-kt-password-meter-control="visibility"]:hover { color: var(--role); background: var(--role-soft); }
.auth__form [data-kt-password-meter-control="visibility"] i { color: inherit; font-size: 18px !important; }
.auth__form [data-kt-password-meter="true"] input[type="password"],
.auth__form [data-kt-password-meter="true"] input[name="password"] { padding-inline-end: 52px; }

/* رابط «نسيت كلمة المرور» في بداية السطر تحت الحقول — بلون هادئ */
.auth__form .flex-stack { justify-content: flex-start !important; }
.auth__form .flex-stack > div:empty { display: none; }
.auth__form .flex-stack .link-primary { color: var(--ink-3) !important; font-weight: 400; font-size: 13px; }
.auth__form .flex-stack .link-primary:hover { color: var(--role) !important; }

/* روابط بوابات الدخول الأخرى (أسفل دخول الدائن) */
.auth__switch {
  margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--ink-3);
}
.auth__form a.auth__switch-debtor {
  display: inline-flex; align-items: center; gap: 6px;
  color: #8A6D28; font-weight: 700;
}
.auth__form a.auth__switch-debtor:hover { color: #65551E; }
.auth__arrow:dir(rtl) { transform: scaleX(-1); }

/* رجوع إلى دخول الدائنين (أعلى دخول المدين والإداري) */
.auth__form a.auth__back-link {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px;
  font-size: 13px; color: var(--ink-3);
}
.auth__form a.auth__back-link:hover { color: var(--role); }
.auth__arrow-back:dir(rtl) { transform: scaleX(-1); }
.auth__form a.auth__staff {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
  font-size: 12px; color: var(--muted);
}
.auth__form a.auth__staff:hover { color: var(--role); }

/* محاذاة موحّدة لبداية السطر كما في التصميم */
.auth__form .text-center { text-align: start !important; }
.auth__form .mb-11 { margin-bottom: 28px !important; }

/* حقل الجوال بعرض الحقول الأخرى */
.auth__form .iti, .auth__form .intl-tel-input { display: block; width: 100%; }
.auth__form .input-group > .iti { flex: 1 1 auto; }
.auth__form .iti input { width: 100% !important; }
.auth__form .input-icon:empty, .auth__form .input-icon .ti-mobile:only-child { display: none; }

.auth__form .form-check-input { accent-color: var(--role); }
/* مربع الموافقة بجانب نصه */
.auth__form .fv-row:has(> .form-check-input) { display: flex; align-items: flex-start; gap: 10px; }
.auth__form .fv-row > .form-check-input { flex: none; width: 20px; height: 20px; margin: 4px 0 0; border: 1.5px solid var(--role) !important; }
.auth__form .fv-row > .form-check-input + label .form-check-label { margin: 0 !important; line-height: 1.8; }
.auth__form .fv-row > .form-check-input.is-invalid { border-color: #A32C2C !important; box-shadow: 0 0 0 3px rgba(163, 44, 44, .12); }
.auth__form .form-check-input:checked { background-color: var(--role); border-color: var(--role) !important; }

.auth__form .btn.btn-primary {
  min-height: 54px; border-radius: var(--radius);
  font-family: var(--f-body); font-size: 16px; font-weight: 600;
  transition: background-color .2s ease, transform .15s ease;
}
.auth__form .btn.btn-primary:active { transform: translateY(1px); }

.auth__form a { color: var(--ink-3); }
.auth__form a:hover { color: var(--role); }
.auth__form .link-primary { color: var(--role) !important; font-weight: 700; }
.auth__form .link-primary:hover { color: var(--role-dark) !important; }

.auth__form .alert {
  border: none; border-inline-start: 2px solid; border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; line-height: 1.8;
}
.auth__form .alert-success { background: var(--role-soft); border-color: var(--role); color: var(--role-dark); }
.auth__form .alert-danger  { background: #FDF1F1; border-color: #A32C2C; color: #7E2323; }

/* صندوق الرسائل — مطابق لـ portal-auth (أخطاء الواجهة والخادم معًا) */
.auth__msgs:empty { display: none; }
.auth__msgs { width: 100%; flex: 0 0 100%; }
.auth__msg {
  margin: 20px 0; padding: 12px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.8; border-inline-start: 2px solid; text-align: start;
}
/* backend texts carry their own line breaks (Arabic line / English line) */
.auth__msg li, .auth__msg--ok > div { white-space: pre-line; }
.auth__msg--error { background: #FDF1F1; border-color: #A32C2C; color: #7E2323; }
.auth__msg--ok    { background: var(--role-soft); border-color: var(--role); color: var(--role); }
.auth__msg strong { font-weight: 700; }
.auth__msg ul { margin: 6px 0 0; padding-inline-start: 18px; list-style: disc; }

.auth__support {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.8; color: var(--muted);
}
.auth__support a { color: var(--role); font-weight: 600; unicode-bidi: isolate; }

/* -------------------------------------------------------- responsive --- */

@media (max-width: 1199.98px) {
  .auth__brandin { padding: 40px 32px 72px; }
  .auth__logo img { width: 300px; }
  .auth__brandcol { margin-top: 32px; max-width: 340px; }
  .auth__hero { margin-top: 32px; }
  .auth__herotitle { font-size: 36px; }
}

@media (max-width: 991.98px) {
  .auth__brand { display: none !important; }
  .auth__form { min-height: 100svh; padding: 0 20px 48px; }

  .auth__mini {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-inline: -20px; padding: 12px 20px;
    background: var(--role); color: #fff;
  }
  .auth__mini img.brand { height: 30px; width: auto; filter: brightness(0) invert(1); }
  .auth__miniclient { display: flex; align-items: center; gap: 10px; }
  .auth__miniclient img { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; }
  .auth__miniclient span { font-size: 12px; line-height: 1.5; color: rgba(255, 255, 255, .92); max-width: 180px; }

  .auth__top { position: static; margin-top: 20px; align-self: flex-start; }
  .auth__form .p-10 { padding: 20px 0 !important; }
  .auth__form h1, .auth__form h2.card-title { font-size: 28px; }
}

@media (max-width: 420px) {
  .auth__miniclient span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .auth *, .auth *::before, .auth *::after { transition-duration: .01ms !important; }
}
.auth__miniclient img.wide + span { display: none; }
