/* ==========================================================================
   منصة إحقاق — تصميم شاشات الدخول (مطابق لـ portal-auth)
   طبقة تصميم فوق Metronic: لا تغيّر النماذج، فقط المظهر.
   ثلاث سمات: دائن (تركوازي) / إداري (أخضر) / مدين (برونزي)
   ========================================================================== */

.ehq-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;

  /* دائن (افتراضي) */
  --role: #176E77; --role-dark: #0F5259;
  --role-soft: rgba(33, 145, 156, .10);
  --role-rgb: 23, 110, 119;
}
.ehq-auth--admin {
  --role: #1C6B4F; --role-dark: #134E38;
  --role-soft: rgba(36, 138, 102, .10);
  --role-rgb: 28, 107, 79;
}
.ehq-auth--debtor {
  --role: #8A6D28; --role-dark: #65551E;
  --role-soft: rgba(138, 109, 40, .10);
  --role-rgb: 138, 109, 40;
}

/* Metronic primary → لون الدور */
.ehq-auth {
  --kt-primary: var(--role);
  --kt-primary-active: var(--role-dark);
  --kt-primary-light: var(--role-soft);
  --kt-primary-rgb: var(--role-rgb);
  --bs-primary: var(--role);
  --bs-primary-rgb: var(--role-rgb);
  --kt-link-color: var(--role);
  --bs-link-color: var(--role);

  background: var(--paper) !important;
  color: var(--ink);
  font-family: var(--f-body) !important;
  -webkit-font-smoothing: antialiased;
}
.ehq-auth ::selection { background: var(--role); color: #fff; }

.ehq-auth h1, .ehq-auth h2, .ehq-auth h3, .ehq-auth .card-title {
  font-family: var(--f-display);
  color: var(--ink);
}

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

.ehq-auth #kt_app_root > .flex-column-fluid { min-height: 100vh; min-height: 100dvh; }

@media (min-width: 992px) {
  .ehq-auth .ehq-brand   { flex: 0 0 45%; width: 45%; }
  .ehq-auth .ehq-auth__form { flex: 1 1 55%; width: 55% !important; }
  .ehq-auth--wide .ehq-brand { flex-basis: 34%; width: 34%; }
  .ehq-auth--wide .ehq-auth__form { flex-basis: 66%; width: 66% !important; }
}

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

.ehq-brand {
  position: relative;
  background: var(--role);
  color: #fff;
  overflow: hidden;
}
@media (min-width: 992px) {
  .ehq-brand { position: sticky; top: 0; height: 100vh; height: 100dvh; align-self: flex-start; }
}

/* الزخرفة الهندسية — علامة إحقاق بلا كلمات، مقصوصة عند حافة اللوحة */
.ehq-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/auth/brand-circuit.png") no-repeat bottom right / contain;
}
[dir="ltr"] .ehq-brand::before { background-position: bottom left; transform: scaleX(-1); }

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

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

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

.ehq-brand__client { display: flex; align-items: center; justify-content: center; gap: 16px; text-align: start; }
.ehq-brand__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);
}
.ehq-brand__clientlogo img { width: 100%; height: 100%; object-fit: contain; }
.ehq-brand__clientname {
  font-size: 17px; font-weight: 700; line-height: 1.55; color: #fff; unicode-bidi: isolate;
}

.ehq-brand__hero {
  width: 100%;
  margin-top: 40px; padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: flex; flex-direction: column; align-items: center;
}
.ehq-auth .ehq-brand__title {
  margin: 0;
  font-family: var(--f-display);
  font-size: clamp(32px, 3.2vw, 46px); font-weight: 700; line-height: 1.3;
  color: #fff; text-wrap: balance;
}
.ehq-brand__lead {
  margin: 12px auto 0; max-width: 32ch;
  font-size: 15px; line-height: 1.9; color: rgba(255, 255, 255, .92);
}
.ehq-brand__support { margin: 16px 0 0; font-size: 13px; line-height: 1.8; color: rgba(255, 255, 255, .82); }
.ehq-brand__support a { color: #fff; font-weight: 600; unicode-bidi: isolate; }
.ehq-brand__support a:hover { color: #fff; text-decoration: underline; }

.ehq-brand__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;
}
.ehq-brand__admin { display: inline-block; vertical-align: middle; margin-inline-start: 6px; opacity: .5; }
.ehq-brand__admin:hover { opacity: 1; }
.ehq-brand__admin img { filter: brightness(0) invert(1); }

.ehq-auth--wide .ehq-brand__logo img { width: 280px; }

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

.ehq-auth .ehq-auth__form { position: relative; background: var(--paper); }

/* مبدّل اللغة (تصميم portal-auth): زر كبسولة بأيقونة الكرة الأرضية */
.ehq-auth .ehq-top { position: absolute; top: 24px; inset-inline-end: 24px; z-index: 5; }
.ehq-auth .ehq-lang {
  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) !important; font-size: 13px; font-weight: 600; line-height: 1;
  text-decoration: none;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.ehq-auth .ehq-lang:hover { border-color: var(--role); color: var(--role) !important; background: var(--role-soft); }
.ehq-auth .ehq-lang svg { opacity: .7; flex: none; }

/* العناوين والنصوص */
.ehq-auth .ehq-auth__form h2.card-title,
.ehq-auth .ehq-auth__form .text-center h1,
.ehq-auth .ehq-auth__form h1.text-dark {
  font-size: 30px !important; font-weight: 700 !important; line-height: 1.35;
}
.ehq-auth .ehq-auth__form h3 { font-size: 16px; font-weight: 500; color: var(--role); }
.ehq-auth .ehq-auth__form .card-text,
.ehq-auth .ehq-auth__form .text-gray-500,
.ehq-auth .ehq-auth__form .text-muted { color: var(--ink-2) !important; font-size: 14px; line-height: 1.8; }

/* الحقول */
.ehq-auth .form-label,
.ehq-auth .ehq-auth__form label:not(.form-check-label):not(.form-check) {
  font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--ink-2);
  margin-bottom: 8px;
}
.ehq-auth .ehq-auth__form .form-control,
.ehq-auth .ehq-auth__form .form-select {
  min-height: 52px; padding: 12px 16px;
  background-color: var(--field) !important;
  border: 1.5px solid transparent !important;
  border-radius: var(--radius) !important;
  color: var(--ink) !important;
  font-family: inherit; font-size: 15px;
  box-shadow: none;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ehq-auth .ehq-auth__form .form-control::placeholder { color: #93A8AD; }
.ehq-auth .ehq-auth__form .form-control:hover,
.ehq-auth .ehq-auth__form .form-select:hover { background-color: #E9F0F1 !important; }
.ehq-auth .ehq-auth__form .form-control:focus,
.ehq-auth .ehq-auth__form .form-select:focus {
  background-color: #fff !important;
  border-color: var(--role) !important;
  box-shadow: 0 0 0 3px var(--role-soft) !important;
  outline: none;
}
.ehq-auth .ehq-auth__form .mb-1 { margin-bottom: 20px !important; }

/* إظهار كلمة المرور — الزر داخل الحقل عند نهايته */
.ehq-auth .ehq-pw { position: relative; display: flex; flex-wrap: nowrap; align-items: stretch; }
.ehq-auth .ehq-pw > .form-control { flex: 1 1 auto; width: 100%; padding-inline-end: 52px !important; }
.ehq-auth .ehq-pw .ehq-pw__toggle {
  position: absolute !important; z-index: 5;
  top: 50% !important; bottom: auto !important;
  inset-inline-end: 6px !important; inset-inline-start: auto !important;
  left: auto; right: auto;
  transform: translateY(-50%) !important;
  margin: 0 !important;
  width: 40px; height: 40px; padding: 0 !important;
  display: flex; align-items: center; justify-content: center;
  background: transparent !important; border: none !important; border-radius: var(--radius) !important;
  color: var(--muted); cursor: pointer;
}
[dir="rtl"] .ehq-auth .ehq-pw .ehq-pw__toggle { left: 6px !important; right: auto !important; }
[dir="ltr"] .ehq-auth .ehq-pw .ehq-pw__toggle { right: 6px !important; left: auto !important; }
.ehq-auth .ehq-pw .ehq-pw__toggle i { font-size: 18px !important; color: inherit; line-height: 1; margin: 0 !important; }
.ehq-auth .ehq-pw .ehq-pw__toggle:hover { color: var(--role); background: var(--role-soft) !important; }

/* «نسيت كلمة المرور» تحت حقل كلمة المرور في بداية السطر */
.ehq-auth .ehq-forgot { justify-content: flex-start; margin-top: -4px; margin-bottom: 8px !important; }

/* الإقرارات */
.ehq-auth .form-check-input { border-color: var(--line); }
.ehq-auth .form-check-input:checked { background-color: var(--role) !important; border-color: var(--role) !important; }
.ehq-auth .form-check-input:focus { box-shadow: 0 0 0 3px var(--role-soft); border-color: var(--role); }

/* الروابط */
.ehq-auth .ehq-auth__form a:not(.btn) { color: var(--role) !important; }
.ehq-auth .ehq-auth__form a.link-primary { font-weight: 700; }
.ehq-auth .ehq-auth__form a:not(.btn):hover { color: var(--role-dark) !important; }
/* «نسيت كلمة المرور» — رابط هادئ كما في التصميم */
.ehq-auth .ehq-auth__form .fs-base.fw-semibold a.link-primary { font-weight: 500; font-size: 13px; color: var(--ink-3) !important; }
.ehq-auth .ehq-auth__form .fs-base.fw-semibold a.link-primary:hover { color: var(--role) !important; }

/* زر الإرسال — يتجاوز ألوان السطر القديمة */
.ehq-auth .ehq-auth__form .btn.btn-primary {
  min-height: 54px;
  background: var(--role) !important;
  border: 1px solid var(--role) !important;
  border-radius: var(--radius) !important;
  color: #fff !important;
  font-family: var(--f-body);
  font-size: 16px; font-weight: 600;
  box-shadow: none !important;
  transition: filter .2s ease, transform .15s ease;
}
.ehq-auth .ehq-auth__form .btn.btn-primary:hover { filter: brightness(.92); }
.ehq-auth .ehq-auth__form .btn.btn-primary:active { transform: translateY(1px); }
.ehq-auth .ehq-auth__form .btn.btn-light,
.ehq-auth .ehq-auth__form .btn.btn-secondary { border-radius: var(--radius); min-height: 54px; }

/* الرسائل */
.ehq-auth .ehq-auth__form .alert {
  border: none; border-inline-start: 2px solid; border-radius: var(--radius);
  font-size: 14px; line-height: 1.8; padding: 12px 16px;
}
.ehq-auth .ehq-auth__form .alert-danger  { background: #FDF1F1; border-color: #A32C2C; color: #7E2323; }
.ehq-auth .ehq-auth__form .alert-success { background: var(--role-soft); border-color: var(--role); color: var(--role); }
.ehq-auth .ehq-auth__form .text-danger { color: #A32C2C !important; }
.ehq-auth .ehq-auth__form span.text-danger { display: inline-block; margin-top: 6px; }

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

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

@media (max-width: 1199.98px) {
  .ehq-brand__in { padding: 40px 32px 72px; }
  .ehq-brand__logo img { width: 300px; }
  .ehq-brand__col { margin-top: 32px; max-width: 340px; }
  .ehq-brand__hero { margin-top: 32px; }
}

/* الجوال: اللوحة تصير شريطًا مضغوطًا أعلى النموذج */
@media (max-width: 991.98px) {
  .ehq-brand::before { content: none; }
  .ehq-brand__in {
    flex-direction: row; justify-content: space-between; gap: 16px;
    padding: 12px 20px;
  }
  .ehq-brand__logo { width: auto; }
  .ehq-brand__logo img { width: auto; height: 30px; }
  .ehq-brand__col { width: auto; max-width: none; margin: 0; }
  .ehq-brand__clientlogo { width: 38px; height: 38px; border-radius: 10px; box-shadow: none; }
  .ehq-brand__client { gap: 10px; }
  .ehq-brand__clientname { font-size: 12px; font-weight: 500; line-height: 1.5; max-width: 180px; color: rgba(255,255,255,.92); }
  .ehq-brand__hero, .ehq-brand__copy { display: none; }

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

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

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

/* ترتيب الأزرار */
.ehq-auth .ehq-auth__form form > .btn.btn-primary { margin-top: 20px; }
.ehq-auth .ehq-auth__form .d-grid > .btn.btn-primary { width: 100%; }
.ehq-auth .ehq-auth__form .divider:empty,
.ehq-auth .ehq-auth__form .divider { margin: 12px 0 !important; }

/* رقم الجوال (intl-tel-input) — عرض كامل داخل العمود */
.ehq-auth .ehq-auth__form .input-group > .input-icon:empty,
.ehq-auth .ehq-auth__form .input-group > .input-icon { display: none; }
.ehq-auth .ehq-auth__form .input-group > .iti,
.ehq-auth .ehq-auth__form .input-group > .intl-tel-input { display: block; flex: 1 1 auto; width: 100%; }
.ehq-auth .ehq-auth__form .iti input.form-control { width: 100%; }
.ehq-auth .ehq-auth__form .iti__selected-flag { border-radius: var(--radius) 0 0 var(--radius); }
.ehq-auth .ehq-auth__form .iti__country-list { z-index: 20; max-width: 320px; }

/* ---------------------------------------------------- الرسائل (portal-auth) --- */

.ehq-auth .ehq-msgs:empty { display: none; }
.ehq-auth .ehq-msg {
  margin: 20px 0; padding: 12px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.8; text-align: start;
  border-inline-start: 2px solid;
}
.ehq-auth .ehq-msg--error { background: #FDF1F1; border-color: #A32C2C; color: #7E2323; }
.ehq-auth .ehq-msg--ok    { background: var(--role-soft); border-color: var(--role); color: var(--role); }
.ehq-auth .ehq-msg strong { font-weight: 600; }
.ehq-auth .ehq-msg ul { margin: 6px 0 0; padding-inline-start: 18px; list-style: disc; }
.ehq-auth .ehq-msg li { margin: 0; }

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

/* زر الإرسال أثناء الإرسال */
.ehq-auth .ehq-auth__form .btn[aria-busy="true"] { pointer-events: none; opacity: .85; }

/* ------------------------------------ روابط الأدوار الأخرى (صفحة دخول الدائن) --- */

.ehq-auth .ehq-auth__form .ehq-alt { text-align: start !important; font-size: 13px !important; color: var(--ink-3) !important; }
.ehq-auth .ehq-auth__form .ehq-alt a { font-weight: 700; }

.ehq-auth .ehq-roles {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  font-size: 13px; line-height: 1.6; color: var(--ink-3);
}
.ehq-auth .ehq-roles__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ehq-auth .ehq-auth__form a.ehq-roles__debtor {
  display: inline-flex; align-items: center; gap: 6px;
  color: #8A6D28 !important; font-weight: 700;
}
.ehq-auth .ehq-auth__form a.ehq-roles__debtor:hover { color: #65551E !important; }
[dir="ltr"] .ehq-auth .ehq-roles__debtor svg { transform: scaleX(-1); }
.ehq-auth .ehq-auth__form a.ehq-roles__staff {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted) !important;
}
.ehq-auth .ehq-auth__form a.ehq-roles__staff:hover { color: var(--ink-2) !important; }
