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

:root {
  --pa-paper:  #FFFFFF;
  --pa-field:  #EFF3F4;

  --pa-ink:    #0C1F24;
  --pa-ink-2:  #3A5459;
  --pa-ink-3:  #4C6A70;
  --pa-muted:  #7E959B;

  --pa-line:   rgba(12, 31, 36, 0.14);

  --pa-radius: 10px;

  --pa-f-display: 'Readex Pro', 'Segoe UI', Tahoma, sans-serif;
  --pa-f-body:    'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

/* -------------------------------------------------------- role themes --- */

.auth, .auth--creditor {
  --role: #176E77; --role-strong: #1A7E88; --role-dark: #0F5259;
  --role-tint: #E9F3F4;
  --role-soft: rgba(33, 145, 156, .10); --role-line: rgba(33, 145, 156, .30);
}
/* الحسابات الإدارية والأمناء */
.auth--admin {
  --role: #1C6B4F; --role-strong: #20805F; --role-dark: #134E38;
  --role-tint: #E8F2ED;
  --role-soft: rgba(36, 138, 102, .10); --role-line: rgba(36, 138, 102, .30);
}
/* المدين */
.auth--debtor {
  --role: #8A6D28; --role-strong: #9C7D30; --role-dark: #65551E;
  --role-tint: #F6F1E3;
  --role-soft: rgba(138, 109, 40, .10); --role-line: rgba(138, 109, 40, .32);
}

/* --------------------------------------------------------------- base --- */

html, body#kt_body { background: var(--pa-paper) !important; }
body#kt_body { overflow-x: clip; }

.auth {
  /* جسر لمتغيرات Metronic حتى تأخذ الأزرار والروابط لون الدور */
  --bs-primary: var(--role);
  --bs-primary-active: var(--role-dark);
  --bs-primary-light: var(--role-tint);
  --bs-link-color: var(--role);
  --bs-link-hover-color: var(--role-dark);
  --bs-text-primary: var(--role);

  flex: 1 0 auto; width: 100%;
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
  color: var(--pa-ink);
  font-family: var(--pa-f-body);
  font-size: 15px; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
.auth--doc { grid-template-columns: minmax(0, 32fr) minmax(0, 68fr); }

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

.auth h1, .auth h2, .auth h3, .auth h4 { font-family: var(--pa-f-display); }

.auth__pane {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

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

.auth__brand {
  order: 1;
  background: var(--role);
  color: #fff;
  overflow: hidden;
  justify-content: flex-start;
}

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

.auth__brandin {
  position: relative; z-index: 1; width: 100%;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 48px 48px 88px;
}

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

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

.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; padding: 6px;
  background: #fff; box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
}
.auth__clientlogo img { width: 100%; height: 100%; object-fit: contain; }
.auth__clientname {
  font-family: var(--pa-f-body); font-size: 17px; font-weight: 700; line-height: 1.55; color: #fff;
  unicode-bidi: isolate;
}

.auth__hero {
  margin-top: 40px; padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.auth__hero:first-child { margin-top: 0; }
.auth .auth__herotitle {
  margin: 0; color: #fff;
  font-size: clamp(30px, 3vw, 44px); font-weight: 700; line-height: 1.3; text-wrap: balance;
}
.auth__herolead { margin: 12px auto 0; font-size: 15px; line-height: 1.9; color: rgba(255, 255, 255, .92); max-width: 34ch; }
.auth__herolead a { color: #fff; font-weight: 600; unicode-bidi: isolate; }
.auth__herolead a:hover { color: #fff; text-decoration: underline; }

.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: rgba(255, 255, 255, .55); margin-inline-start: 6px; }
.auth__copy a:hover { color: #fff; }

.auth__mini { display: none; }

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

.auth__form {
  order: 2; background: var(--pa-paper);
  padding: 32px 24px; align-items: stretch;
}

.auth__formin {
  position: relative; width: min(440px, 100%);
  margin-inline-start: clamp(48px, 6vw, 120px); margin-inline-end: auto;
  margin-block: auto; padding-block: 56px 16px;
}
.auth__formin--wide { width: min(560px, 100%); }
.auth--doc .auth__formin { width: min(760px, 100%); margin-inline: auto; }

/* تحييد الحاويات الموروثة من القالب القديم */
.auth .content-wrapper, .auth .content-body, .auth .auth-wrapper, .auth .auth-inner { width: 100%; }
.auth .auth-inner.row { margin: 0; }
.auth .auth-inner.row > * { padding-inline: 0; }

.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(--pa-line); border-radius: 999px;
  color: var(--pa-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; }

/* العناوين */
.auth__formin h1, .auth__formin h2.card-title {
  color: var(--pa-ink) !important;
  font-size: 28px !important; font-weight: 700 !important; line-height: 1.35;
  text-align: start; text-wrap: balance; margin-bottom: 8px !important;
}
.auth__formin .text-center.mb-11 { text-align: start !important; margin-bottom: 24px !important; }
.auth__formin .card-text, .auth__formin .text-gray-500.fw-semibold.fs-6 {
  font-size: 14px !important; line-height: 1.8; color: var(--pa-ink-2) !important; text-align: start;
}
.auth__formin form { margin-top: 24px; }

/* الحقول */
.auth .form-label, .auth__formin label:not(.form-check-label) {
  font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--pa-ink-2); margin-bottom: 8px;
}
.auth .form-control, .auth .form-select {
  min-height: 52px; padding: 12px 16px;
  background-color: var(--pa-field) !important;
  border: 1.5px solid transparent !important; border-radius: var(--pa-radius) !important;
  color: var(--pa-ink); font-family: inherit; font-size: 15px; font-weight: 400;
  box-shadow: none;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.auth .form-control::placeholder { color: #93A8AD; }
.auth .form-control:hover, .auth .form-select:hover { background-color: #E9F0F1 !important; }
.auth .form-control:focus, .auth .form-select:focus {
  background-color: #fff !important; border-color: var(--role) !important;
  box-shadow: 0 0 0 3px var(--role-soft) !important; outline: none;
}
.auth .form-select { background-position: left 16px center; }
[dir="ltr"] .auth .form-select { background-position: right 16px center; }
.auth .fv-row.mb-8, .auth .mb-8 { margin-bottom: 18px !important; }
.auth .row.g-3.mb-9 { margin-bottom: 18px !important; }
.auth .mb-1 { margin-bottom: 14px !important; }

/* إظهار كلمة المرور */
.auth .input-group-text {
  min-height: 40px; min-width: 40px; justify-content: center;
  background: transparent; border: none; border-radius: 10px; color: var(--pa-muted);
}
.auth .input-group-text:hover { color: var(--role); background: var(--role-soft); }
.auth .position-relative:has(> [data-kt-password-meter-control="visibility"]) .form-control { padding-inline-end: 52px; }
.auth [data-kt-password-meter-control="visibility"] {
  top: 50% !important; bottom: auto !important;
  right: 6px !important; left: auto !important;
  transform: translateY(-50%) !important;
  width: 40px; height: 40px; margin: 0 !important; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--pa-muted); cursor: pointer;
}
[dir="rtl"] .auth [data-kt-password-meter-control="visibility"] { right: auto !important; left: 6px !important; }
.auth [data-kt-password-meter-control="visibility"]:hover { color: var(--role); background: var(--role-soft); }
.auth [data-kt-password-meter-control="visibility"] i { margin: 0 !important; color: inherit; }
.auth [data-kt-password-meter-control="highlight"] .bg-active-success.active { background-color: var(--role) !important; }

/* الجوال — intl-tel-input */
.auth .iti { width: 100%; }
.auth .iti input.form-control { width: 100% !important; }
.auth .iti__selected-flag, .auth .iti--separate-dial-code .iti__selected-flag { border-radius: var(--pa-radius) 0 0 var(--pa-radius); background: transparent; }

/* الموافقة */
.auth .form-check-input { accent-color: var(--role); border-color: var(--role-line) !important; }
.auth .form-check-input:checked { background-color: var(--role); border-color: var(--role) !important; }
.auth .form-check-label { color: var(--pa-ink-2) !important; font-size: 14px !important; }

/* الروابط */
.auth__formin a, .auth__formin .link-primary { color: var(--role) !important; font-weight: 600; }
.auth__formin a:hover, .auth__formin .link-primary:hover { color: var(--role-dark) !important; }
.auth__formin .text-gray-500.text-center { text-align: start !important; font-size: 13px !important; color: var(--pa-ink-3) !important; }

/* الأزرار */
.auth .btn.btn-primary {
  min-height: 54px; margin-top: 8px;
  border: 1px solid var(--role) !important; border-radius: var(--pa-radius) !important;
  background: var(--role) !important; color: #fff !important;
  font-family: var(--pa-f-body); font-size: 16px; font-weight: 600;
  box-shadow: none !important;
  transition: filter .2s ease, transform .15s ease;
}
.auth .btn.btn-primary:hover, .auth .btn.btn-primary:focus { filter: brightness(.92); }
.auth .btn.btn-primary:active { transform: translateY(1px); }
.auth .btn.btn-light, .auth .btn.btn-secondary {
  min-height: 54px; border-radius: var(--pa-radius) !important;
  background: var(--role-tint) !important; color: var(--role) !important; border: 1px solid var(--role-line) !important;
  font-weight: 600;
}

/* الرسائل — مطابقة لـ .auth__msg في portal-auth (رسائل الخادم + رسائل التحقق في المتصفح) */
.auth .auth__msg {
  margin: 20px 0 0; padding: 12px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.8; text-align: start;
  border: 0; border-inline-start: 2px solid;
}
.auth .auth__msg--error { background: #FDF1F1; border-color: #A32C2C; color: #7E2323; }
.auth .auth__msg--ok    { background: var(--role-soft); border-color: var(--role); color: var(--role); }
.auth .auth__msg strong { font-weight: 700; }
.auth .auth__msg ul { margin: 6px 0 0; padding-inline-start: 18px; list-style: disc; }
.auth .auth__msg li { white-space: pre-line; }
.auth .auth__msg[hidden] { display: none; }
.auth .auth__msg + form, .auth .auth__msg + .auth__msg { margin-top: 12px; }

/* حقل غير صالح — نفس حدّ portal-auth (#A32C2C) */
.auth .form-control.pa-invalid, .auth .form-select.pa-invalid,
.auth .pa-invalid .form-control {
  border-color: #A32C2C !important; background-color: #fff !important;
}
.auth .form-check-input.pa-invalid { border-color: #A32C2C !important; box-shadow: 0 0 0 3px rgba(163, 44, 44, .12); }
.auth .form-control.pa-invalid:focus, .auth .form-select.pa-invalid:focus { box-shadow: 0 0 0 3px rgba(163, 44, 44, .12) !important; }

/* تلميح تطابق كلمة المرور الحي (#message) — بلا الصور المكسورة */
.auth #message { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.6; }
.auth #message img { display: none; }

.auth .alert {
  padding: 12px 16px; border-radius: 10px; border: none;
  border-inline-start: 2px solid; font-size: 14px; line-height: 1.8;
}
.auth .text-danger { color: #A32C2C !important; }

/* الفاصل السفلي يحوي أحيانًا ملاحظات (مثل: تحقق من البريد غير المرغوب) */
.auth .divider { display: block; margin: 16px 0 0 !important; border: 0; }
.auth .divider::before, .auth .divider::after { content: none !important; display: none !important; }
.auth .divider .divider-text { display: block; padding: 0; font-size: 13px; line-height: 1.8; color: var(--pa-ink-3); text-align: start; }
.auth .divider .divider-text:empty, .auth .divider:not(:has(.divider-text *)) .divider-text { display: none; }

/* «هل نسيت كلمة المرور» — رابط هادئ في بداية السطر (كان flex-stack يدفعه للطرف الآخر) */
.auth__formin form > .d-flex.flex-stack { justify-content: flex-start !important; margin: 4px 0 20px !important; }
.auth__formin form > .d-flex.flex-stack > div:empty { display: none; }
.auth__formin form > .d-flex.flex-stack a,
.auth__formin form > .d-flex.flex-stack a.link-primary {
  color: var(--pa-ink-3) !important; font-weight: 400; font-size: 13px;
}
.auth__formin form > .d-flex.flex-stack a:hover { color: var(--role) !important; }

/* «ليس لديك حساب؟ تسجيل جديد» */
.auth__formin form + .divider + .text-gray-500 { margin-top: 20px; font-size: 14px !important; color: var(--pa-ink-2) !important; }
.auth__formin .text-gray-500 a.link-primary { font-weight: 700; }

/* روابط أنواع الحسابات الأخرى (المدين / الموظفين) */
.auth__roles { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--pa-line); }
.auth__rolesrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; line-height: 1.6; color: var(--pa-ink-3); }
.auth__formin a.auth__rolelink { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.auth__formin a.auth__rolelink--debtor { color: #8A6D28 !important; }
.auth__formin a.auth__rolelink--debtor:hover { color: #65551E !important; }
[dir="rtl"] .auth__rolelink svg { transform: scaleX(-1); }
.auth__formin a.auth__staff {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 16px;
  font-size: 12.5px; font-weight: 400; color: var(--pa-muted) !important;
}
.auth__formin a.auth__staff:hover { color: var(--role) !important; }

/* عنوان نوع الحساب تحت «تسجيل الدخول» — مثل <small> في portal-auth */
.auth__formin h3 { margin: 0 0 4px; font-size: 16px !important; font-weight: 500 !important; color: var(--role) !important; font-family: var(--pa-f-body); }

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

@media (max-width: 1100px) {
  .auth__brandin { padding: 40px 32px 32px; }
  .auth__logo img { width: 300px; }
  .auth__brandcol { margin-top: 32px; max-width: 340px; }
  .auth__hero { margin-top: 32px; }
  .auth__form { padding: 24px 20px; }
}

@media (max-width: 991px) {
  .auth, .auth--doc { grid-template-columns: 1fr; min-height: 100svh; }
  .auth__brand { display: none; }
  .auth__form { order: 1; min-height: 100svh; justify-content: flex-start; padding: 0 20px 48px; }

  .auth__mini {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    width: calc(100% + 40px); 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; padding: 3px; }
  .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__formin, .auth__formin--wide, .auth--doc .auth__formin {
    width: 100%; max-width: 560px; margin-inline: auto; margin-block: 0; margin-top: 20px; padding-block: 0;
  }
  .auth__formin h1, .auth__formin h2.card-title { font-size: 26px !important; }
}

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

@media (prefers-reduced-motion: reduce) {
  .auth *, .auth *::before, .auth *::after { transition-duration: .01ms !important; }
}

/* زر إظهار كلمة المرور داخل الحقل (يُنقل عبر js/auth.js) */
.auth .pa-pw { position: relative; flex-wrap: nowrap; }
.auth .pa-pw .form-control { padding-inline-end: 52px; border-radius: var(--pa-radius) !important; }
.auth .pa-pw .input-group-text {
  position: absolute; top: 50%; inset-inline-end: 6px; transform: translateY(-50%); z-index: 5;
  width: 40px; height: 40px; min-height: 0; padding: 0; cursor: pointer;
}

/* زر الإظهار المضاف لحقول التأكيد — يتبع ظهور الحقل نفسه (jQuery show/hide) */
.auth .pa-pw--added { display: block; }
.auth .pa-pw--added .form-control { width: 100%; }
.auth .pa-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%); z-index: 5;
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 10px;
  color: var(--pa-muted); cursor: pointer;
}
[dir="rtl"] .auth .pa-eye { right: auto; left: 6px; }
.auth .pa-eye:hover, .auth .pa-eye.is-on { color: var(--role); background: var(--role-soft); }
.auth .pa-pw--added:has(> input[style*="display: none"]) > .pa-eye,
.auth .pa-pw--added:has(> input[style*="display:none"]) > .pa-eye { display: none; }

/* زر صفحات الدخول الأصلي بعد نقله داخل الحقل — موضعه صريح لكل اتجاه */
.auth .pa-pw > .input-group-text { right: 6px; left: auto; }
[dir="rtl"] .auth .pa-pw > .input-group-text { right: auto; left: 6px; }
