/* ==========================================================================
   CrysMed — Provider login / register (provider-auth.html) + MFA step (provider-login-mfa.html)
   2026-10-09. Loaded after the shared head-links (so after auth.css). auth.css is shared with
   member-auth.html and is NOT edited; everything here is scoped to these two pages by being
   linked from them alone. Same approach as member-auth.css (crysmed-audit/APPROACH.md §5).

   Desktop changes approved 2026-10-09: login form spacing, "password first + code buttons"
   sign-in methods, readable links, numbered register sections + tidy file pickers, MFA code
   box, UI polish. Fields, names, actions and order of the forms are unchanged.
   ========================================================================== */

/* ---------- All sizes ---------- */

/* Login forms (Password / SMS / WhatsApp) had no spacing at all — unlike the register form they
   aren't .auth-panel, so the fields touched each other. Same 12px rhythm as the register form. */
[data-login-method-panel] { display: flex; flex-direction: column; gap: var(--sp-3); }
[data-login-method-panel][hidden] { display: none; }
[data-login-method-panel] .btn-block { margin-top: var(--sp-1); }
[data-login-method-panel] .auth-switch { margin-top: var(--sp-2) !important; } /* inline was sp-3 + gap */
[data-login-method-panel] .auth-legal { margin-top: 0; text-align: center; }

/* "Forgot password?" was still the 10px dashed "under development" pill (.dev-tag) */
.auth-row a.dev-tag {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--brand-700);
  cursor: pointer;
}
.auth-row a.dev-tag:hover { color: var(--brand-900); text-decoration: underline; }

/* Links that looked like plain text */
.auth-card .auth-switch a,
.auth-card .checkbox-field a { font-weight: var(--fw-bold); color: var(--brand-700); }
.auth-card .auth-switch a:hover,
.auth-card .checkbox-field a:hover { color: var(--brand-900); text-decoration: underline; }

/* Sign-in methods: "password first + code buttons" */
.login-alt { display: flex; flex-direction: column; gap: var(--sp-3); }
.login-alt__label { margin: var(--sp-2) 0 0; text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--ink-500); }
.login-alt__btns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-3); }
.login-alt__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--white);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--ink-900);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.login-alt__btn svg { width: 18px; height: 18px; flex: none; color: var(--brand-700); }
.login-alt__btn[data-login-method-tab="whatsapp"] svg { color: #1a9e4b; }
.login-alt__btn:hover { border-color: var(--brand-700); background: var(--brand-tint); }

.login-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  margin: -4px 0 0 -2px;
  padding: 6px 2px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--brand-700);
  cursor: pointer;
}
.login-back svg { width: 16px; height: 16px; }
.login-back:hover { color: var(--brand-900); }
.login-method-title { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--ink-900); letter-spacing: var(--tracking-tight); }

/* Register: numbered sections */
.reg-step {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--sp-4);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--ink-900);
  letter-spacing: var(--tracking-tight);
}
.auth-panel > .reg-step:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.reg-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-700);
  font-size: 13px;
  font-weight: var(--fw-bold);
}
.reg-step__opt { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--ink-500); letter-spacing: 0; }
.reg-step__hint { margin: -4px 0 var(--sp-1); }
.reg-note { margin: 0; }

/* Consent checkboxes: text + link flow as one sentence (as flex items the "Provider Terms" link
   split off into its own column on phones); box stays aligned with the first line */
.auth-card .auth-panel > .checkbox-field { display: block; position: relative; padding-left: 25px; line-height: 1.45; }
.auth-card .auth-panel > .checkbox-field input { position: absolute; left: 0; top: 2px; margin: 0; }

/* File pickers: tidy upload box instead of the raw "Choose file / No file chosen" control */
.auth-card .field input[type="file"] {
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--ink-500);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.auth-card .field input[type="file"]:hover { border-color: var(--brand-700); background: var(--brand-tint); }
.auth-card .field input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--white);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--brand-700);
  cursor: pointer;
}

/* MFA step: big, spaced, centred code box */
.auth-card .otp-input {
  min-height: 56px;
  font-size: 24px;
  font-weight: var(--fw-bold);
  letter-spacing: .5em;
  text-indent: .5em; /* letter-spacing adds space after the last digit: keep it visually centred */
  text-align: center;
}
.auth-card .otp-input::placeholder { color: var(--line-strong); }

/* ==========================================================================
   UI/UX POLISH (same as member-auth.css). All motion respects "reduce motion".
   A) All sizes   B) Phones + touch tablets only
   ========================================================================== */

/* ---------- A) All sizes ---------- */
.auth-shell {
  --press-ease: cubic-bezier(.2, .8, .2, 1);
  --sheet-ease: cubic-bezier(.32, .72, 0, 1);
}

/* Sliding Vendor Login / Vendor Registration switch */
.auth-tabs { position: relative; isolation: isolate; }
.auth-tabs::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px - 2px);
  border-radius: var(--r-sm);
  background: var(--white);
  box-shadow: var(--shadow-1);
  transition: transform .32s var(--sheet-ease);
}
.auth-tabs:has(.auth-tab:nth-child(2).is-active)::before { transform: translateX(calc(100% + 4px)); }
.auth-tab, .auth-tab.is-active { background: transparent; box-shadow: none; transition: color .25s ease, transform .14s var(--press-ease); }

/* Switching forms / sign-in method: the new form fades + rises in */
.auth-panel:not([hidden]),
[data-login-method-panel]:not([hidden]) { animation: auth-panel-in .32s var(--sheet-ease) both; }

/* Field focus: brand border + soft glow, label tint */
.auth-card .field { transition: color .2s ease; }
.auth-card .field:focus-within { color: var(--brand-700); }
.auth-card .field :is(input, select) {
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.auth-card .field :is(input, select):focus {
  outline: none;
  border-color: var(--brand-700);
  box-shadow: 0 0 0 4px var(--brand-tint);
}
.auth-card .field :is(input, select):focus::placeholder { color: var(--ink-300); }
.auth-card :focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; }
.auth-card .field :is(input, select):focus-visible { outline: none; }

.auth-card .form-alert { animation: auth-panel-in .3s var(--sheet-ease) both; }

/* Submit loading state (class set by provider-auth.js) */
.auth-card .btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.auth-card .btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}

/* ---------- B) Phones + touch tablets only: press feedback ---------- */
@media (max-width: 1023.98px), (min-width: 1024px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
  .auth-shell :is(a, button, label, input, select) { -webkit-tap-highlight-color: transparent; }

  .auth-card .btn,
  .auth-switch button,
  .auth-row a,
  .login-alt__btn,
  .login-back {
    transition: transform .14s var(--press-ease), background-color .2s ease, border-color .2s ease, color .2s ease;
  }
  .auth-card .btn:active { transform: scale(.97); filter: brightness(.94); }
  .auth-tab:active { transform: scale(.96); }
  .login-alt__btn:active { transform: scale(.97); background: var(--surface); }
  .auth-switch button:active,
  .auth-switch a:active,
  .auth-row a:active,
  .login-back:active { opacity: .6; }
  .password-toggle { border-radius: 50%; transition: background-color .15s ease, color .15s ease; }
  .password-toggle:active { background: var(--surface); color: var(--ink-900); }
  .auth-card .checkbox-field { border-radius: 10px; transition: background-color .15s ease; }
  .auth-card .checkbox-field:active { background: var(--surface); }
  .auth-card .checkbox-field input[type="checkbox"] { transition: transform .14s var(--press-ease); }
  .auth-card .checkbox-field:active input[type="checkbox"] { transform: scale(.9); }
}

/* No "stuck" hover effects on touch screens */
@media (hover: none) {
  .auth-shell .btn-primary:hover { background: var(--premium-500); }
  .auth-shell .auth-row a:hover,
  .auth-shell .auth-switch button:hover,
  .auth-shell .auth-switch a:hover,
  .auth-shell .checkbox-field a:hover { color: var(--brand-700); text-decoration: none; }
  .auth-shell .password-toggle:hover { color: var(--ink-300); }
  .auth-shell .login-alt__btn:hover { border-color: var(--line-strong); background: var(--white); }
  .auth-shell .field input[type="file"]:hover { border-color: var(--line-strong); background: var(--surface); }
}

@keyframes auth-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .auth-panel:not([hidden]), [data-login-method-panel]:not([hidden]), .auth-card .form-alert { animation: none; }
  .auth-tabs::before { transition: none; }
  .auth-card .btn:active, .auth-tab:active, .login-alt__btn:active { transform: none; }
  .auth-card .btn.is-loading::after { animation-duration: 1.6s; }
}

/* ---------- Phones, tablets and touch tablets in landscape: touch sizes ---------- */
@media (max-width: 1023.98px), (min-width: 1024px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
  /* 48px fields, 16px text (stops iOS Safari zooming in on focus) */
  .auth-card .field input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]),
  .auth-card .field select {
    min-height: 48px;
    font-size: 16px;
  }
  .auth-card .field input.otp-input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]) { min-height: 56px; font-size: 24px; } /* beats the 48px/16px rule above */
  /* +971 picker took 110px (40% of a phone field): compact, same height as the field */
  .auth-card select.phone-input__prefix { flex: none; width: 92px; max-width: none; padding-inline: 10px; }
  .auth-card .password-toggle { width: 44px; height: 44px; }
  .auth-card .password-input input { padding-right: 48px; }

  .auth-tabs { margin-bottom: 20px; }
  /* labels went to 2 lines; equal halves so the sliding pill always lines up */
  .auth-tab { flex: 1 1 0; min-width: 0; min-height: 44px; font-size: 14px; white-space: nowrap; padding-inline: 8px; }

  .auth-card .checkbox-field { min-height: 36px; gap: 10px; font-size: 14px; }
  .auth-card .checkbox-field input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
  .auth-card .auth-panel > .checkbox-field { padding: 7px 0 7px 30px; }
  .auth-card .auth-panel > .checkbox-field input { top: 7px; }

  .auth-card .btn-block { min-height: 48px; font-size: 15px; }
  .auth-row a.dev-tag { font-size: 14px; padding: 8px 0; }
  .auth-switch { font-size: 14px; }
  .auth-switch button { padding: 8px 4px; }
  .auth-legal { font-size: 12px; }
  .login-alt__btn { min-height: 48px; font-size: 14px; }
  .login-back { font-size: 14px; padding: 8px 2px; }
  .auth-card .field input[type="file"] { padding: 12px; font-size: 14px; }
  .auth-card .field input[type="file"]::file-selector-button { padding: 9px 14px; font-size: 14px; }
}

/* ---------- Stacked layout (≤980px, where auth.css stacks the two cards):
   the form comes FIRST; the Provider access panel follows below, complete and more compact. ---------- */
@media (max-width: 980px) {
  .auth-shell__grid > .auth-card { order: -1; }
  .auth-aside { padding: 28px 24px; }
  .auth-aside h1 { font-size: 26px; line-height: 1.15; }
  .auth-aside__sub { margin-bottom: 16px; }
  .auth-benefits { margin-top: 8px; margin-bottom: 20px; gap: 14px; }
  .auth-benefits b { font-size: 14px; }
  .auth-benefits span { font-size: 12px; }
  .auth-stats { padding-top: 16px; }
  .auth-stats span { font-size: 12px; }
}

/* ---------- Phones ---------- */
@media (max-width: 599.98px) {
  .auth-shell { padding-block: 12px 24px; }
  .auth-shell__grid { gap: 16px; }
  .auth-card { padding: 18px 16px 20px; border-radius: 16px; }
  .auth-aside { padding: 24px 20px; border-radius: 16px; }
  .auth-aside h1 { font-size: 24px; }
  .auth-stats b { font-size: 20px; }
  .reg-step { font-size: 16px; }
  .login-alt__btns { gap: 10px; }
  .login-alt__btn { padding-inline: 8px; gap: 6px; white-space: nowrap; } /* "WhatsApp code" wrapped */
  /* MFA page title: its size is an inline style in provider-login-mfa.html (fs-xl), 2 big lines on phones */
  .auth-card > h1 { font-size: 24px !important; }
}
@media (max-width: 379.98px) {
  .auth-tab, .login-alt__btn { font-size: 13px; }
  .auth-tab { padding-inline: 4px; } /* "Vendor Registration" = 124px in a 133px half */
}
