/* ============================================================
   NEXO PRINT — Auth Modal (reusable overlay)
   Drop-in login/register dialog that fades the page behind it.
   Requires: tokens.css
   Usage:  NexoAuth.open()   /   NexoAuth.close()
   ============================================================ */

/* ── page-behind blur while modal is open ── */
.nx-auth-blur { filter: blur(4px) saturate(0.92); transition: filter var(--duration-normal) var(--ease-out); pointer-events: none; user-select: none; }

/* ── backdrop ── */
.nx-auth-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--duration-normal) var(--ease-out);
  overflow-y: auto;
}
.nx-auth-overlay.is-open { opacity: 1; }

/* ── card ── */
.nx-auth {
  position: relative; width: min(452px, 100%);
  background: #fff; border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-8) var(--space-8) var(--space-6);
  transform: translateY(14px) scale(0.98);
  transition: transform var(--duration-normal) var(--ease-spring);
}
.nx-auth-overlay.is-open .nx-auth { transform: translateY(0) scale(1); }
@media (max-width: 480px) {
  .nx-auth { padding: var(--space-6) var(--space-5) var(--space-5); border-radius: var(--radius-xl); }
}

/* close */
.nx-auth__close {
  position: absolute; top: var(--space-4); inset-inline-end: var(--space-4);
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: transparent; color: var(--color-text-faint); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.nx-auth__close:hover { background: var(--color-neutral-100); color: var(--color-text); }
.nx-auth__close svg { width: 20px; height: 20px; }

/* logo */
.nx-auth__logo { display: block; height: 38px; width: auto; margin: 0 auto var(--space-5); }

/* headings */
.nx-auth h2 { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.015em; color: var(--color-neutral-900); text-align: center; margin: 0 0 var(--space-2); }
.nx-auth__sub { font-size: 0.9375rem; line-height: 1.6; color: var(--color-text-muted); text-align: center; margin: 0 0 var(--space-6); }

/* stages */
.nx-stage { display: none; }
.nx-stage.is-active { display: block; animation: nxFade var(--duration-normal) var(--ease-out); }
@keyframes nxFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* method segmented control */
.nx-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--color-neutral-100); border-radius: var(--radius-lg); padding: 4px; margin-bottom: var(--space-5); }
.nx-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0.6rem; border: 0; background: transparent; border-radius: var(--radius-md);
  font: inherit; font-weight: 700; font-size: 0.9rem; color: var(--color-text-muted); cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.nx-seg button svg { width: 17px; height: 17px; }
.nx-seg button.is-active { background: #fff; color: var(--color-navy); box-shadow: var(--shadow-xs); }

/* fields */
.nx-field { margin-bottom: var(--space-4); }
.nx-field > label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.nx-input-wrap { position: relative; }
.nx-input-wrap .nx-pfx { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--color-text-faint); pointer-events: none; display: inline-flex; }
.nx-input-wrap .nx-pfx svg { width: 18px; height: 18px; }
.nx-auth input[type="tel"], .nx-auth input[type="email"], .nx-auth input[type="password"], .nx-auth input[type="text"] {
  width: 100%; min-height: 50px; padding: 0.75rem var(--space-4) 0.75rem 2.75rem;
  border: 1.5px solid var(--color-border); border-radius: var(--radius-md);
  background: #fff; font: inherit; font-size: 1rem; color: var(--color-text);
  transition: border var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.nx-auth input::placeholder { color: var(--color-text-faint); }
.nx-auth input:focus { outline: none; border-color: var(--color-blue); box-shadow: var(--shadow-focus); }
.nx-field.has-error input { border-color: var(--color-danger); }
.nx-field.has-error .nx-err { display: flex; }
.nx-err { display: none; align-items: center; gap: 5px; font-size: 0.8125rem; color: var(--color-danger); margin-top: 6px; }
.nx-err svg { width: 14px; height: 14px; flex: none; }
/* LTR fields hold the icon on the left, so pad start */
.nx-input-wrap.ltr input { direction: ltr; text-align: start; }

/* show/hide-password eye — floats at the free end of the input (the prefix
   icon owns the other end); without absolute positioning it collapses to 0px
   after the full-width input. */
.nx-input-wrap .nx-eye {
  position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 8px;
  color: var(--color-slate, #575C69);
}
.nx-input-wrap .nx-eye:hover { color: var(--color-navy, #1B3A6B); }
.nx-input-wrap .nx-eye svg { width: 20px; height: 20px; display: block; }
.nx-input-wrap:has(.nx-eye) input { padding-inline-end: 44px; }

/* primary button */
.nx-btn {
  width: 100%; min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: var(--radius-lg);
  font: inherit; font-weight: 700; font-size: 1.0625rem; cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.nx-btn:active { transform: translateY(1px); }
.nx-btn--primary { background: var(--color-navy); color: #fff; }
.nx-btn--primary:hover { background: var(--color-navy-dark); }
.nx-btn--ghost { background: #fff; color: var(--color-navy); border-color: var(--color-border-strong); }
.nx-btn--ghost:hover { background: var(--color-neutral-50); border-color: var(--color-navy); }
.nx-btn svg { width: 18px; height: 18px; }
/* loading spinner on primary button (real network calls) */
.nx-btn.is-loading { pointer-events: none; opacity: 0.9; }
.nx-btn.is-loading .nx-btn-label, .nx-btn.is-loading > svg { display: none; }
.nx-spin { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: nxSpin 0.6s linear infinite; display: none; }
.nx-btn.is-loading .nx-spin { display: block; }
@keyframes nxSpin { to { transform: rotate(360deg); } }

/* trust note under primary */
.nx-note { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.8125rem; color: var(--color-text-faint); margin-top: var(--space-4); }
.nx-note svg { width: 14px; height: 14px; }

/* OTP */
.nx-otp { display: flex; gap: 8px; direction: ltr; justify-content: center; margin: var(--space-2) 0 var(--space-5); }
.nx-otp input { width: 52px; height: 60px; padding: 0; text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--color-navy); border: 1.5px solid var(--color-border); border-radius: var(--radius-lg); }
.nx-otp input.filled { border-color: var(--color-navy); background: var(--color-neutral-50); }
@media (max-width: 420px) { .nx-otp input { width: 46px; height: 54px; font-size: 1.3rem; } }
.nx-resend { text-align: center; font-size: 0.875rem; color: var(--color-text-muted); margin-bottom: var(--space-5); }
.nx-resend button { background: none; border: 0; color: var(--color-blue); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.nx-resend button:disabled { color: var(--color-text-faint); cursor: default; }

/* dest chip in otp sub */
.nx-dest { font-weight: 800; color: var(--color-navy); direction: ltr; unicode-bidi: isolate; }

/* divider */
.nx-divider { display: flex; align-items: center; gap: 12px; margin: var(--space-6) 0 var(--space-4); color: var(--color-text-faint); font-size: 0.8125rem; font-weight: 600; }
.nx-divider::before, .nx-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }

/* staff strip */
.nx-staff {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  width: 100%; padding: var(--space-3) var(--space-4);
  background: var(--color-neutral-50); border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg); cursor: pointer; text-align: start;
  font: inherit; color: var(--color-text);
  transition: border var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.nx-staff:hover { border-color: var(--color-navy); background: #fff; }
.nx-staff__l { display: flex; align-items: center; gap: var(--space-3); }
.nx-staff__ico { width: 38px; height: 38px; border-radius: var(--radius-md); background: var(--color-navy); color: #fff; display: grid; place-items: center; flex: none; }
.nx-staff__ico svg { width: 19px; height: 19px; }
.nx-staff__tx { display: flex; flex-direction: column; gap: 2px; }
.nx-staff__t { font-size: 0.9375rem; font-weight: 700; line-height: 1.2; }
.nx-staff__s { font-size: 0.75rem; color: var(--color-text-muted); }
.nx-staff__chev { color: var(--color-neutral-400); }
.nx-staff__chev svg { width: 18px; height: 18px; }

/* back link */
.nx-back { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--color-blue); font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; padding: 0; margin-top: var(--space-4); }
.nx-back svg { width: 15px; height: 15px; }
.nx-center { text-align: center; }

/* password stage badge */
.nx-staff-badge { display: inline-flex; align-items: center; gap: 7px; background: var(--color-sky); color: var(--color-navy); font-weight: 700; font-size: 0.8125rem; padding: 6px 14px; border-radius: var(--radius-full); margin: 0 auto var(--space-4); }
.nx-staff-badge svg { width: 15px; height: 15px; }
.nx-forgot { display: block; text-align: end; font-size: 0.8125rem; font-weight: 600; color: var(--color-blue); margin-top: -6px; margin-bottom: var(--space-4); }

/* ── profile stage (new customers — real backend requires name) ── */
.nx-input-plain { width: 100%; min-height: 50px; padding: 0.75rem var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); background: #fff; font: inherit; font-size: 1rem; color: var(--color-text); transition: border var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
.nx-input-plain::placeholder { color: var(--color-text-faint); }
.nx-input-plain:focus { outline: none; border-color: var(--color-blue); box-shadow: var(--shadow-focus); }
.nx-select { width: 100%; min-height: 50px; padding: 0.75rem var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); background: #fff; font: inherit; font-size: 1rem; color: var(--color-text); }
.nx-select:focus { outline: none; border-color: var(--color-blue); box-shadow: var(--shadow-focus); }
.nx-req { color: var(--color-danger); }

/* success */
.nx-success { text-align: center; padding: var(--space-2) 0 var(--space-3); }
.nx-success__ok { width: 76px; height: 76px; border-radius: 50%; background: var(--color-success-bg); color: var(--color-success); display: grid; place-items: center; margin: 0 auto var(--space-5); animation: nxPop var(--duration-slow) var(--ease-spring); }
.nx-success__ok svg { width: 38px; height: 38px; }
@keyframes nxPop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.nx-promo { display: inline-flex; align-items: center; gap: 8px; background: var(--color-sky); color: var(--color-navy); font-weight: 700; font-size: 0.875rem; padding: 0.5rem 1rem; border-radius: var(--radius-full); margin-bottom: var(--space-5); }
.nx-promo code { background: #fff; padding: 2px 9px; border-radius: var(--radius-sm); letter-spacing: 0.05em; }

/* legal foot */
.nx-legal { text-align: center; font-size: 0.8125rem; color: var(--color-text-faint); margin: var(--space-5) 0 0; line-height: 1.6; }
.nx-legal a { color: var(--color-text-muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .nx-auth-overlay, .nx-auth, .nx-stage, .nx-success__ok { transition: none; animation: none; }
}
