/* ==========================================================================
   Lightning Payroll — authentication forms (login / forgotten / password /
   update credit card). Self-contained, namespaced under .lp-auth so it never
   touches the rest of the storefront. Built on the existing Rainbow theme
   tokens, with a single light-mode override of component-scoped variables so
   every rule below adapts to both dark and active-light-mode automatically.
   Loaded after style.min.css (see common/header.tpl).
   ========================================================================== */

.lp-auth {
  /* Component-scoped tokens — dark scope (theme default). */
  --lp-auth-surface: #11131a;
  --lp-auth-surface-2: rgba(255, 255, 255, 0.03);
  --lp-auth-text: var(--color-body, #afafaf);
  --lp-auth-heading: var(--color-heading, #ffffff);
  --lp-auth-muted: #7e828c;
  --lp-auth-border: rgba(255, 255, 255, 0.12);
  --lp-auth-border-strong: rgba(255, 255, 255, 0.22);
  --lp-auth-input-bg: rgba(255, 255, 255, 0.02);
  --lp-auth-accent: #059dff;
  --lp-auth-accent-2: #6549d5;
  --lp-auth-accent-3: #fb5343;
  --lp-auth-ok: #3eb75e;
  --lp-auth-warn: #ff8f3c;
  --lp-auth-bad: #ff5a52;
  --lp-auth-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  --lp-auth-radius: 16px;
  --lp-auth-radius-sm: 10px;
}

body.active-light-mode .lp-auth {
  /* Override only the component tokens for light mode. */
  --lp-auth-surface: #ffffff;
  --lp-auth-surface-2: #f6f8fb;
  --lp-auth-text: #4a4f57;
  --lp-auth-heading: #14161c;
  --lp-auth-muted: #7b8190;
  --lp-auth-border: #e4e8ee;
  --lp-auth-border-strong: #cfd6e0;
  --lp-auth-input-bg: #ffffff;
  --lp-auth-shadow: 0 24px 60px -28px rgba(20, 30, 60, 0.22);
}

/* ---- Centred page wrapper -------------------------------------------------- */
.lp-auth-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(28px, 6vw, 80px) 16px;
  position: relative;
  z-index: 2;
}

.lp-auth-card {
  width: 100%;
  max-width: 452px;
  background: var(--lp-auth-surface);
  border: 1px solid var(--lp-auth-border);
  border-radius: var(--lp-auth-radius);
  box-shadow: var(--lp-auth-shadow);
  padding: clamp(26px, 4vw, 44px);
  position: relative;
  overflow: hidden;
  animation: lp-auth-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Gradient hairline along the top edge — the theme's signature accent. */
.lp-auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(95deg, var(--lp-auth-accent), var(--lp-auth-accent-2) 55%, var(--lp-auth-accent-3));
}

.lp-auth-card__head {
  text-align: center;
  margin-bottom: 26px;
}

.lp-auth-card__title {
  color: var(--lp-auth-heading);
  font-family: var(--font-primary, "Inter", sans-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  line-height: 1.2;
}

.lp-auth-card__subtitle {
  color: var(--lp-auth-muted);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 auto;
  max-width: 34ch;
}

.lp-auth-card__subtitle a {
  color: var(--lp-auth-accent);
  text-decoration: none;
  font-weight: 600;
}
.lp-auth-card__subtitle a:hover { text-decoration: underline; }

/* Staggered field entrance. */
.lp-auth-card .lp-auth-field,
.lp-auth-card .lp-auth-actions,
.lp-auth-card .lp-auth-alt {
  animation: lp-auth-fade 0.5s ease both;
}
.lp-auth-card .lp-auth-field:nth-of-type(1) { animation-delay: 0.06s; }
.lp-auth-card .lp-auth-field:nth-of-type(2) { animation-delay: 0.12s; }
.lp-auth-card .lp-auth-field:nth-of-type(3) { animation-delay: 0.18s; }
.lp-auth-card .lp-auth-actions { animation-delay: 0.24s; }

/* ---- Fields ---------------------------------------------------------------- */
.lp-auth-field { margin-bottom: 18px; }

.lp-auth-label {
  display: block;
  color: var(--lp-auth-heading);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.lp-auth-input-wrap { position: relative; }

/* Field control — also retargets Bootstrap .form-control inside the card. */
.lp-auth-input,
.lp-auth .form-control {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  background: var(--lp-auth-input-bg) !important;
  color: var(--lp-auth-heading) !important;
  border: 2px solid var(--lp-auth-border) !important;
  border-radius: var(--lp-auth-radius-sm) !important;
  font-size: 15px;
  font-family: var(--font-primary, "Inter", sans-serif);
  transition: border-color var(--transition, 0.25s) ease, box-shadow var(--transition, 0.25s) ease, background var(--transition, 0.25s) ease;
  -webkit-appearance: none;
  appearance: none;
}
.lp-auth-input.has-affix { padding-right: 46px; }

.lp-auth-input::placeholder,
.lp-auth .form-control::placeholder { color: var(--lp-auth-muted); opacity: 1; }

.lp-auth-input:focus,
.lp-auth .form-control:focus {
  outline: none;
  border-color: var(--lp-auth-accent) !important;
  box-shadow: 0 0 0 4px rgba(5, 157, 255, 0.16) !important;
  background: var(--lp-auth-input-bg) !important;
}

.lp-auth-input.is-invalid { border-color: var(--lp-auth-bad) !important; }
.lp-auth-input.is-valid { border-color: var(--lp-auth-ok) !important; }

/* Keep autofilled fields on-palette in both themes (the theme has no autofill rule). */
.lp-auth-input:-webkit-autofill,
.lp-auth-input:-webkit-autofill:hover,
.lp-auth-input:-webkit-autofill:focus,
.lp-auth .form-control:-webkit-autofill {
  -webkit-text-fill-color: var(--lp-auth-heading);
  -webkit-box-shadow: 0 0 0 1000px var(--lp-auth-surface) inset !important;
  caret-color: var(--lp-auth-heading);
  transition: background-color 9999s ease-in-out 0s;
}

/* Show/hide password affix button. */
.lp-auth-affix {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--lp-auth-muted);
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
  transition: color var(--transition, 0.2s) ease, background var(--transition, 0.2s) ease;
}
.lp-auth-affix:hover { color: var(--lp-auth-accent); background: var(--lp-auth-surface-2); }
.lp-auth-affix:focus-visible { outline: 2px solid var(--lp-auth-accent); outline-offset: 2px; }
.lp-auth-affix svg { width: 19px; height: 19px; display: block; }

/* ---- Field-level error text ------------------------------------------------ */
.lp-auth-fielderror {
  display: none;
  color: var(--lp-auth-bad);
  font-size: 12.5px;
  margin-top: 6px;
  line-height: 1.4;
}
.lp-auth-fielderror.is-shown { display: block; }

/* ---- Password strength + requirement checklist ---------------------------- */
.lp-auth-meter { margin: 10px 0 4px; }

.lp-auth-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.lp-auth-strength__track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--lp-auth-border);
  overflow: hidden;
}
.lp-auth-strength__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--lp-auth-bad);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}
.lp-auth-strength__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--lp-auth-muted);
  min-width: 52px;
  text-align: right;
}
.lp-auth-strength[data-level="1"] .lp-auth-strength__fill { width: 25%; background: var(--lp-auth-bad); }
.lp-auth-strength[data-level="2"] .lp-auth-strength__fill { width: 50%; background: var(--lp-auth-warn); }
.lp-auth-strength[data-level="3"] .lp-auth-strength__fill { width: 78%; background: #c9d11b; }
.lp-auth-strength[data-level="4"] .lp-auth-strength__fill { width: 100%; background: var(--lp-auth-ok); }

.lp-auth-reqs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
}
.lp-auth-req {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--lp-auth-muted);
  transition: color 0.3s ease;
}
.lp-auth-req__tick {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--lp-auth-border-strong);
  position: relative;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lp-auth-req__tick::after {
  content: "";
  position: absolute;
  left: 4.6px;
  top: 1.6px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lp-auth-req.is-met { color: var(--lp-auth-ok); }
.lp-auth-req.is-met .lp-auth-req__tick {
  background: var(--lp-auth-ok);
  border-color: var(--lp-auth-ok);
  transform: scale(1.05);
}
.lp-auth-req.is-met .lp-auth-req__tick::after { transform: rotate(45deg) scale(1); }

.lp-auth-hint {
  font-size: 11.5px;
  color: var(--lp-auth-muted);
  margin: 8px 0 0;
  line-height: 1.45;
}

/* ---- OTP input ------------------------------------------------------------- */
.lp-auth-otp {
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.5em;
  font-weight: 600;
  padding-right: 14px !important;
  padding-left: calc(14px + 0.5em) !important;
}

/* ---- Alerts (inline, announced) ------------------------------------------- */
.lp-auth-alert {
  display: none;
  border-radius: var(--lp-auth-radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.lp-auth-alert.is-shown { display: block; animation: lp-auth-fade 0.3s ease both; }
.lp-auth-alert--danger {
  color: #ff8b85;
  background: rgba(255, 90, 82, 0.1);
  border-color: rgba(255, 90, 82, 0.32);
}
.lp-auth-alert--success {
  color: var(--lp-auth-ok);
  background: rgba(62, 183, 94, 0.1);
  border-color: rgba(62, 183, 94, 0.32);
}
.lp-auth-alert a { color: inherit; font-weight: 700; text-decoration: underline; }
body.active-light-mode .lp-auth-alert--danger { color: #c0392b; }

/* ---- Actions / buttons / links -------------------------------------------- */
.lp-auth-actions { margin-top: 22px; }

/* Full-width primary button reusing the theme's gradient pill .btn-default. */
.lp-auth .btn.btn-default.lp-auth-btn,
.lp-auth-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}
.lp-auth-btn[disabled],
.lp-auth-btn.is-busy { opacity: 0.65; pointer-events: none; }

.lp-auth-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -3px;
  animation: lp-auth-spin 0.7s linear infinite;
}

.lp-auth-alt {
  margin-top: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--lp-auth-muted);
}
.lp-auth-alt a { color: var(--lp-auth-accent); font-weight: 600; text-decoration: none; }
.lp-auth-alt a:hover { text-decoration: underline; }

.lp-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--lp-auth-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.lp-auth-divider::before,
.lp-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--lp-auth-border);
}

.lp-auth-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: var(--lp-auth-muted);
  background: var(--lp-auth-surface-2);
  border: 1px solid var(--lp-auth-border);
  border-radius: var(--lp-auth-radius-sm);
  padding: 11px 13px;
  margin-bottom: 18px;
  line-height: 1.5;
}
.lp-auth-note svg { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 1px; color: var(--lp-auth-accent); }

/* ---- Themed modal (confirm / password step-up) ---------------------------- */
.lp-auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 12, 0.62);
  backdrop-filter: blur(3px);
  animation: lp-auth-fade 0.2s ease both;
}
.lp-auth-modal__dialog {
  width: 100%;
  max-width: 400px;
  background: var(--lp-auth-surface);
  color: var(--lp-auth-text);
  border: 1px solid var(--lp-auth-border);
  border-radius: var(--lp-auth-radius);
  box-shadow: var(--lp-auth-shadow);
  padding: 26px;
  animation: lp-auth-rise 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.lp-auth-modal__title { color: var(--lp-auth-heading); font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.lp-auth-modal__body { font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
.lp-auth-modal__actions { display: flex; gap: 10px; justify-content: flex-end; }
.lp-auth-modal__btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease, background 0.2s ease;
}
.lp-auth-modal__btn--ghost {
  background: transparent;
  color: var(--lp-auth-text);
  border: 1px solid var(--lp-auth-border-strong);
}
.lp-auth-modal__btn--ghost:hover { background: var(--lp-auth-surface-2); }
.lp-auth-modal__btn--primary { background: linear-gradient(95deg, var(--lp-auth-accent), var(--lp-auth-accent-2)); color: #fff; }
.lp-auth-modal__btn--danger { background: var(--lp-auth-accent-3); color: #fff; }
.lp-auth-modal__btn:hover { filter: brightness(1.07); }
.lp-auth-modal__field { margin-bottom: 16px; }

@keyframes lp-auth-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes lp-auth-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes lp-auth-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .lp-auth-card,
  .lp-auth-card .lp-auth-field,
  .lp-auth-card .lp-auth-actions,
  .lp-auth-card .lp-auth-alt,
  .lp-auth-alert.is-shown,
  .lp-auth-modal,
  .lp-auth-modal__dialog {
    animation: none !important;
  }
  .lp-auth-strength__fill,
  .lp-auth-req__tick,
  .lp-auth-req__tick::after { transition: none !important; }
  .lp-auth-spinner { animation: none !important; }
}

/* Screen-reader-only live status (password requirement progress). */
.lp-auth-sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .lp-auth-reqs { grid-template-columns: 1fr; }
}
