/*
 * Aura Pro — autenticação customer-facing (Workstream 2).
 *
 * Escopo isolado em `.auth-body` para não vazar regras para o restante do
 * tema. Reutiliza os tokens de marca já definidos em `theme.css`
 * (`--brand-rose`, `--brand-gold`, ...) e adiciona apenas o necessário para
 * o fluxo de autenticação.
 */

.auth-body,
.customer-password-card {
  --auth-surface: #ffffff;
  --auth-surface-muted: #fdf8f6;
  --auth-border: #eadfdc;
  --auth-border-strong: #dcc8c5;
  --auth-text: #2f2321;
  --auth-muted: #6d5854;
  --auth-error: #a3323d;
  --auth-error-surface: #fdf1f2;
  --auth-error-border: rgba(163, 50, 61, 0.28);
  --auth-success: #1f7a4d;
  --auth-success-surface: #eef8f2;
  --auth-focus-ring: rgba(144, 89, 87, 0.22);
  --auth-radius: 1rem;
  --auth-radius-sm: 0.75rem;
  --auth-control-height: 3rem;
}

.auth-body {
  background:
    radial-gradient(120% 90% at 50% -20%, #fdf5f2 0%, rgba(255, 255, 255, 0) 62%),
    var(--bg-main);
}

/* ------------------------------------------------------------------ shell */

.auth-shell {
  width: 100%;
  max-width: 29rem;
  margin: 0 auto;
  padding-bottom: 3rem;
}

.auth-progress {
  margin-bottom: 1.25rem;
}

.auth-card {
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius);
  background: var(--auth-surface);
  box-shadow:
    0 20px 45px -32px rgba(63, 40, 38, 0.5),
    0 2px 6px rgba(63, 40, 38, 0.05);
}

.auth-header {
  margin-bottom: 1.4rem;
  text-align: center;
}

.auth-title {
  margin: 0 0 0.4rem;
  color: var(--auth-text);
  font-size: clamp(1.25rem, 4.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.auth-subtitle {
  margin: 0;
  color: var(--auth-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------- campos */

.auth-field {
  margin-bottom: 1rem;
}

.auth-label {
  margin-bottom: 0.35rem;
  color: var(--auth-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.auth-control {
  min-height: var(--auth-control-height);
  border-color: var(--auth-border-strong);
  border-radius: var(--auth-radius-sm);
}

.auth-control:focus,
.auth-control:focus-visible {
  border-color: var(--brand-rose);
  box-shadow: 0 0 0 0.2rem var(--auth-focus-ring);
}

.auth-control.is-invalid {
  border-color: var(--auth-error);
}

.auth-control.is-invalid:focus {
  box-shadow: 0 0 0 0.2rem rgba(163, 50, 61, 0.2);
}

.auth-control[disabled],
.auth-control[readonly] {
  background-color: var(--auth-surface-muted);
  color: var(--auth-muted);
  opacity: 1;
}

.auth-field-error {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  margin-top: 0.45rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--auth-error-border);
  border-radius: 0.6rem;
  background: var(--auth-error-surface);
  color: var(--auth-error);
  font-size: 0.85rem;
  line-height: 1.45;
}

.auth-field-error .bi {
  flex: 0 0 auto;
  margin-top: 0.1rem;
  line-height: 1;
}

.auth-hint {
  margin: 0.35rem 0 0;
  color: var(--auth-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* --------------------------------------------------------- senha (reveal) */

.auth-password {
  position: relative;
  display: block;
}

.auth-password .auth-control {
  padding-right: 3.25rem;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--auth-radius-sm);
  background: transparent;
  color: var(--auth-muted);
  transform: translateY(-50%);
}

.auth-password-toggle:hover {
  color: var(--brand-rose-dark);
  background: var(--auth-surface-muted);
}

.auth-password-toggle:focus-visible {
  outline: 0;
  color: var(--brand-rose-dark);
  border-color: var(--brand-rose);
  box-shadow: 0 0 0 0.2rem var(--auth-focus-ring);
}

.auth-password-toggle[aria-pressed="true"] {
  color: var(--brand-rose);
}

.auth-password-toggle .bi {
  font-size: 1.05rem;
  line-height: 1;
}

/* ------------------------------------------------------------- OTP visual */

.auth-otp {
  position: relative;
  display: block;
}

/* Sem JavaScript o input real permanece visível como campo normal. */
.auth-otp-input {
  display: block;
  width: 100%;
  min-height: var(--auth-control-height);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--auth-border-strong);
  border-radius: var(--auth-radius-sm);
  background: var(--auth-surface);
  color: var(--auth-text);
  font-size: 1.125rem;
  letter-spacing: 0.35em;
}

.auth-otp-input:focus,
.auth-otp-input:focus-visible {
  border-color: var(--brand-rose);
  box-shadow: 0 0 0 0.2rem var(--auth-focus-ring);
  outline: 0;
}

.auth-otp-input.is-invalid {
  border-color: var(--auth-error);
}

.auth-otp-slots {
  display: none;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
}

.auth-otp-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 3.25rem;
  border: 1px solid var(--auth-border-strong);
  border-radius: var(--auth-radius-sm);
  background: var(--auth-surface);
  color: var(--auth-text);
  font-size: clamp(1rem, 4.2vw, 1.35rem);
  font-weight: 600;
  line-height: 1;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    transform 0.15s ease;
}

/* Só com JS o componente vira slots; o input real segue no DOM, focado e
   utilizável por autofill, teclado e leitor de tela. */
.auth-otp[data-otp-enhanced="1"] .auth-otp-slots {
  display: grid;
}

.auth-otp[data-otp-enhanced="1"] .auth-otp-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--auth-radius-sm);
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 16px;
  letter-spacing: 0;
  opacity: 1;
  outline: 0;
  box-shadow: none;
}

.auth-otp[data-otp-enhanced="1"]:focus-within .auth-otp-slot.is-active {
  border-color: var(--brand-rose);
  background: var(--auth-surface-muted);
  box-shadow: 0 0 0 0.2rem var(--auth-focus-ring);
}

.auth-otp[data-otp-enhanced="1"] .auth-otp-slot.is-filled {
  border-color: var(--auth-border-strong);
  background: var(--auth-surface-muted);
}

.auth-otp[data-otp-enhanced="1"].is-complete .auth-otp-slot {
  border-color: var(--auth-success);
  background: var(--auth-success-surface);
}

.auth-otp[data-otp-invalid="1"] .auth-otp-slot,
.auth-otp[data-otp-invalid="1"] .auth-otp-input {
  border-color: var(--auth-error);
}

.auth-otp[data-otp-invalid="1"] .auth-otp-slots {
  animation: auth-otp-shake 0.32s ease;
}

@keyframes auth-otp-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* --------------------------------------------------------------- botões */

.auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  min-height: var(--auth-control-height);
  border-radius: var(--auth-radius-sm);
  font-weight: 600;
}

.auth-submit {
  margin-top: 0.35rem;
}

/* --------------------------------------------------- senha x código (login) */

.auth-options {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.auth-option-title {
  margin: 0 0 0.6rem;
  color: var(--auth-text);
  font-size: 1rem;
  font-weight: 600;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--auth-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--auth-border);
}

.auth-secondary {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--auth-border);
}

.auth-secondary-links {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}

/* ------------------------------------------- reenvio de código (cooldown) */

.auth-resend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-resend-timer {
  color: var(--auth-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.auth-resend-hint {
  margin: 0;
  color: var(--auth-muted);
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
}

.auth-resend-status {
  margin: 0;
  color: var(--auth-success);
  font-size: 0.85rem;
  text-align: center;
}

.auth-resend-status:empty {
  display: none;
}

.auth-button[disabled],
.auth-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.72;
}

.auth-secondary-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  color: var(--brand-rose);
  font-weight: 500;
  text-decoration: none;
}

.auth-secondary-links a:hover {
  color: var(--brand-rose-dark);
  text-decoration: underline;
}

.auth-form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

/* -------------------------------------------------------------- mensagens */

.auth-success {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(31, 122, 77, 0.25);
  border-radius: 0.6rem;
  background: var(--auth-success-surface);
  color: var(--auth-success);
  font-size: 0.85rem;
  line-height: 1.45;
}

.auth-body .app-global-messages {
  max-width: 29rem;
  margin-right: auto;
  margin-left: auto;
}

/* --------------------------------------------- progress steps no shell */

.auth-progress .progress-steps-wrap {
  padding-bottom: 0;
  /* A utility Bootstrap `justify-content-center` usa !important; o alinhamento
     efetivo do stepper é controlado pelas margens automáticas da lista. */
  justify-content: flex-start !important;
}

/* Em telas estreitas a lista pode encolher e quebrar em linhas: os quatro
   passos permanecem visíveis e acessíveis, o overflow fica contido no próprio
   wrapper e nunca chega ao documento. Continua centralizada quando há espaço. */
.auth-progress .progress-steps-list {
  min-width: 0;
  flex-wrap: wrap !important;
  margin-right: auto;
  margin-left: auto;
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .auth-otp[data-otp-invalid="1"] .auth-otp-slots {
    animation: none;
  }

  /* Reduced motion desliga motion, não layout: nenhum `transform: none`
     genérico aqui, para não zerar transforms estruturais. */
  .auth-otp-slot,
  .auth-card,
  .auth-button,
  .auth-control {
    transition: none !important;
    animation: none !important;
  }

  /* O `translateY(-50%)` do botão de senha centraliza o controle dentro do
     input: é layout estático e precisa sobreviver ao reduced motion. */
  .auth-password-toggle {
    transition: none !important;
    animation: none !important;
    transform: translateY(-50%);
  }
}

/* ----------------------------------------------------------- responsivo */

@media (max-width: 575.98px) {
  .auth-shell {
    max-width: 100%;
  }

  .auth-card {
    padding: 1.15rem 0.95rem 1.3rem;
  }

  /* Progress steps dentro do shell: compacta sem duplicar a lógica de passos. */
  .auth-progress .progress-step {
    min-width: 0;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
  }

  .auth-progress .progress-step .step-index {
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.8rem;
  }

  .auth-progress .progress-step .step-label {
    font-size: 0.72rem;
  }

  .auth-otp-slots {
    gap: 0.3rem;
  }

  .auth-otp-slot {
    min-height: 3rem;
    border-radius: 0.6rem;
  }
}

@media (max-width: 359.98px) {
  .auth-card {
    padding: 1rem 0.75rem 1.15rem;
  }

  .auth-otp-slots {
    gap: 0.25rem;
  }

  .auth-otp-slot {
    min-height: 2.85rem;
    font-size: 1rem;
  }
}
