/* ==========================================================================
   منصة إحقاق — شاشات الدخول (تسجيل الدخول / التسجيل / استعادة كلمة المرور)
   ملف مستقل بذاته: لا يعتمد على style.bundle.css.
   سمتان: الموظف (تركوازي) / الإدارة (أخضر)
   ========================================================================== */

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

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

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

  --ok:         #1E7A4C;
  --warn:       #A5670E;
  --danger:     #A32C2C;

  --radius:     10px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  --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;
}

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

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0; overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px; line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--f-display); font-weight: 600; margin: 0; line-height: 1.3; }
p { margin: 0; text-wrap: pretty; }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--role); outline-offset: 3px;
}

.skip-link {
  position: absolute; top: -60px; inset-inline-start: 16px; z-index: 50;
  background: var(--role, #176E77); color: #fff;
  padding: 12px 20px; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 12px; }

::selection { background: var(--role, #176E77); color: #fff; }

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

/* الموظف */
.auth, .auth--client {
  --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);
}

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

/* Split: brand 45% / form 55% — first track is the brand panel
   (start side: right in Arabic, left in English) */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); }

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

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

/* Background watermark — the Ehqaq circuit mark (same as portal-auth) */
.auth__brand::before {
  content: ""; position: absolute; bottom: -110px; inset-inline-start: -80px;
  width: min(600px, 120%); height: 557px;
  pointer-events: none; opacity: .18;
  background-repeat: no-repeat; background-size: contain;
  background-position: bottom right;
  background-image: url("../../images/auth/brand-circuit.png");
}
[dir="ltr"] .auth__brand::before { background-position: bottom left; transform: scaleX(-1); }

.auth__form { order: 2; background: var(--paper); padding: var(--sp-8) var(--sp-6); align-items: stretch; }

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

.auth__brandin {
  position: sticky; top: 0; 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: var(--sp-12) var(--sp-12) 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; display: block; filter: brightness(0) invert(1); }

.auth__brandcol {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center;
  margin-top: var(--sp-10);
}

.auth__client { display: flex; align-items: center; justify-content: center; text-align: start; gap: var(--sp-4); }
.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: cover; display: block; }
.auth__clientname { font-size: 17px; font-weight: 700; line-height: 1.55; color: #fff; }
.auth__clientname .auth__clientmain { display: block; margin: 0; font-size: inherit; font-weight: inherit; letter-spacing: 0; text-transform: none; color: #fff; }
.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: var(--sp-10); padding-top: var(--sp-6); border-top: 1px solid rgba(255,255,255,.18); display: flex; flex-direction: column; align-items: center; }
.auth__herotitle { font-size: clamp(32px, 3.1vw, 46px); font-weight: 700; line-height: 1.3; color: #fff; text-wrap: balance; }
.auth__herolead { margin-top: var(--sp-3); font-size: 15px; line-height: 1.9; color: rgba(255, 255, 255, .92); max-width: 34ch; }

.auth__copy {
  position: absolute; bottom: var(--sp-8); inset-inline: var(--sp-12);
  font-size: 12px; line-height: 1.8; color: rgba(255, 255, 255, .82); text-align: center;
}

.auth__mini { display: none; }

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

.auth__formin {
  position: relative; width: min(420px, 100%);
  margin-inline-start: clamp(48px, 6vw, 120px);
  margin-inline-end: auto;
  margin-block: auto;
  padding-block: var(--sp-10) var(--sp-4);
}
.auth__formin--wide { width: min(760px, 100%); margin-inline: auto; }

.auth__top { position: absolute; top: var(--sp-6); inset-inline-end: var(--sp-6); 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; }

.auth__h { font-size: 30px; font-weight: 700; line-height: 1.35; text-align: start; text-wrap: balance; }
.auth__h small { display: block; margin-top: var(--sp-2); font-size: 16px; font-weight: 500; color: var(--role); }
.auth__lead { margin-top: var(--sp-2); font-size: 14px; line-height: 1.8; color: var(--ink-2); text-align: start; }

.auth__fields { margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-5); }

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field > label { font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--ink-2); text-align: start; }

.field input:not([type="checkbox"]):not([type="hidden"]), .field select {
  width: 100%; min-height: 52px; padding: 12px 16px;
  background: var(--field); border: 1.5px solid transparent; border-radius: var(--radius);
  color: var(--ink); font-family: inherit; font-size: 15px;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.field input::placeholder { color: #93A8AD; }
/* LTR values (email, numbers) keep their direction but align with the page in Arabic */
[dir="rtl"] .field input[dir="ltr"] { text-align: right; }
[dir="rtl"] .field input[dir="ltr"]:placeholder-shown { text-align: right; }
[dir="rtl"] .field .iti input[dir="ltr"] { text-align: left; }
.field input:hover { background: #E9F0F1; }
.field input:focus {
  background: #fff; border-color: var(--role); outline: none;
  box-shadow: 0 0 0 3px var(--role-soft);
}

.field__note { font-size: 12.5px; line-height: 1.7; color: var(--ink-3); text-align: start; }
.field__note a { color: var(--role); font-weight: 600; }
.field__note a:hover { text-decoration: underline; }

/* Live feedback under a field (server ID / claim check, password match) */
.field__status { font-size: 13px; line-height: 1.6; text-align: start; }
.field__status:empty { display: none; }
.field__status > span { display: inline-flex; align-items: center; gap: 6px; }
.field__status svg { flex: none; }
.field__status--ok  { color: var(--ok); }
.field__status--err { color: #A32C2C; }

/* Invalid after a failed check — same red as portal-auth */
.field input[aria-invalid="true"]:not([type="checkbox"]) { border-color: #A32C2C; background: #fff; }
.field input[aria-invalid="true"]:not([type="checkbox"]):focus { box-shadow: 0 0 0 3px rgba(163, 44, 44, .12); }
.consent input[aria-invalid="true"] { outline: 2px solid #A32C2C; outline-offset: 2px; }

/* Password: the toggle sits inside the field, on the end edge */
.pw { position: relative; display: flex; }
.field .pw input:not([type="checkbox"]) { flex: 1 1 auto; min-width: 0; padding-inline-end: 52px; }
.pw__toggle {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--muted); cursor: pointer; padding: 0;
}
.pw__toggle:hover { color: var(--role); background: var(--role-soft); }
.pw__toggle .pw__off { display: none; }
.pw__toggle[aria-pressed="true"] { color: var(--role); }
.pw__toggle[aria-pressed="true"] .pw__on { display: none; }
.pw__toggle[aria-pressed="true"] .pw__off { display: block; }

/* Password strength meter */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pw-meter i { height: 4px; border-radius: 4px; background: #DCE5E7; transition: background .2s ease; }
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: var(--role-strong); }
.pw-meter[data-score="4"] i { background: var(--ok); }

/* Phone field — intl-tel-input (same countries as before), styled like
   portal-auth's .tel prefix: mono dial code, separated from the number */
.field .iti { display: block; width: 100%; }
.field .iti input[type="text"], .field .iti input[type="tel"] { width: 100% !important; text-align: left; }
.field .iti--separate-dial-code .iti__selected-flag {
  padding: 0 12px 0 14px; gap: 6px;
  background: transparent;
  border-inline-end: 1px solid var(--line);
  border-start-start-radius: var(--radius); border-end-start-radius: var(--radius);
}
.field .iti--separate-dial-code .iti__selected-flag:hover,
.field .iti--separate-dial-code .iti__selected-flag:focus { background: rgba(12, 31, 36, .05); outline: none; }
.field .iti__selected-dial-code { font-family: var(--f-mono); font-size: 14px; color: var(--ink-2); margin-left: 6px; }
.field .iti__arrow { border-top-color: var(--ink-3); margin-left: 6px; }
.field .iti__arrow--up { border-top: none; border-bottom-color: var(--ink-3); }
.field .iti__country-list {
  margin-top: 6px; padding: 6px 0; max-width: 340px; max-height: 260px;
  font-family: var(--f-body); font-size: 14px; line-height: 1.5; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(12, 31, 36, .14);
}
.field .iti__country-list { overflow-x: hidden; white-space: normal; width: min(340px, calc(100vw - 40px)); }
.field .iti__country { padding: 8px 14px; display: flex; align-items: center; }
.field .iti__country-name { flex: 0 1 auto; }
.field .iti__country.iti__highlight { background: var(--role-soft); }
.field .iti__dial-code { font-family: var(--f-mono); color: var(--muted); }
.field .iti__divider { border-bottom-color: var(--line); margin: 4px 0; padding: 0; }

.consent { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; line-height: 1.8; color: var(--ink-2); cursor: pointer; text-align: start; }
.consent input[type="checkbox"] {
  flex-shrink: 0; width: 20px; height: 20px; margin: 3px 0 0;
  accent-color: var(--role); cursor: pointer;
}
.consent a { color: var(--role); text-decoration: underline; }

.auth__forgot { display: block; font-size: 13px; line-height: 1.6; color: var(--ink-3); text-align: start; }
.auth__forgot:hover { color: var(--role); }

.auth__submit {
  margin-top: var(--sp-6); width: 100%; min-height: 54px;
  border: 1px solid var(--role); border-radius: var(--radius);
  background: var(--role); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: filter .2s ease, transform .15s ease;
}
.auth__submit:hover { filter: brightness(.92); }
.auth__submit:active { transform: translateY(1px); }
.auth__submit[disabled] { opacity: .7; cursor: progress; }
.auth__submit > span { display: block; }

.auth__alt { margin-top: var(--sp-5); text-align: start; font-size: 13.5px; line-height: 1.6; color: var(--ink-3); }
.auth__alt a { color: var(--role); font-weight: 700; }
.auth__alt a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- messages --- */
/* Same as portal-auth: error = title + bullet list · ok = tinted role box */

.auth__msg {
  margin-top: var(--sp-5); padding: 12px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.8; border-inline-start: 2px solid;
  text-align: start;
}
.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 ul { margin: 6px 0 0; padding-inline-start: 18px; list-style: disc; }
.auth__msg strong { font-weight: 700; }
.auth__msg p { margin: 2px 0 0; }

/* Terms page inside the signup shell */
.auth__terms { margin-top: var(--sp-2); font-size: 14.5px; line-height: 1.95; color: var(--ink-2); text-align: start; }
.auth__terms .login-form-head h2 { font-size: 28px; font-weight: 700; color: var(--ink); margin-bottom: var(--sp-4); }
.auth__terms h4 { font-family: var(--f-display); font-size: 17px; font-weight: 600; color: var(--role); margin: var(--sp-6) 0 var(--sp-2); }
.auth__terms ul { margin: 0; padding-inline-start: 20px; }
.auth__terms li { margin-bottom: 6px; }

.auth__hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

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

@media (max-width: 1100px) {
  .auth__brandin { padding: var(--sp-10) var(--sp-8) 88px; }
  .auth__logo img { width: 300px; }
  .auth__brandcol { margin-top: var(--sp-8); max-width: 340px; }
  .auth__hero { margin-top: var(--sp-8); }
  .auth__herotitle { font-size: 32px; }
  .auth__copy { inset-inline: var(--sp-8); }
  .auth__form { padding: var(--sp-6) var(--sp-5); }
  .auth__formin { margin-inline: auto; }
}

@media (max-width: 820px) {
  .auth { grid-template-columns: minmax(0, 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; display: block; filter: brightness(0) invert(1); }
  .auth__miniclient { display: flex; align-items: center; gap: 10px; }
  .auth__miniclient img { width: 38px; height: 38px; object-fit: cover; border-radius: 10px; display: block; }
  .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: var(--sp-5); align-self: flex-start; }
  .auth__formin { width: 100%; max-width: 460px; margin-inline: auto; margin-block: 0; margin-top: var(--sp-5); padding-block: 0; }
  .auth__formin--wide { max-width: 760px; }
  .auth__h { font-size: 26px; }
}

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

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