/*
 * SX Club (SX PKR) — Design System do fluxo de cadastro nativo (/registration/*)
 * Cobre 100% das telas do guia docs/integracao-novo-site.md:
 * CPF, atalho CPF anterior, celular, e-mail, senha (criar / login / código+senha),
 * confirmação de código, depósito Pix + QR Code + Copia e Cola + status SSE,
 * handoff (branchUrl c/ contagem 5s, lojas iOS/Android/Windows, aprovação pendente),
 * erros mapeados, rate-limit 429, Turnstile e banner LGPD de cookies.
 */

/* ---------- Modal principal do cadastro ---------- */
.reg-modal {
  width: min(500px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--text);
  background: transparent;
}
.reg-modal::backdrop {
  background: rgba(2, 6, 12, .8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.reg-modal[open] {
  animation: tg-modal-in .32s cubic-bezier(.2, .8, .2, 1);
}
.reg-modal__inner {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(20px, 3vw, 30px);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background:
    radial-gradient(75% 50% at 85% 0%, rgba(var(--glow-a), .22), transparent 70%),
    radial-gradient(50% 45% at 10% 100%, rgba(var(--glow-c), .42), transparent 70%),
    linear-gradient(#06101d, #050c16) padding-box,
    linear-gradient(160deg, rgba(220, 240, 255, .24), rgba(220, 240, 255, .06) 50%, rgba(var(--glow-b), .42)) border-box;
  box-shadow: 0 40px 100px -24px rgba(0, 0, 0, .95), 0 0 50px -22px rgba(var(--glow-a), .4);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.reg-modal__inner::-webkit-scrollbar { display: none; }
@media (max-width: 540px) {
  .reg-modal {
    width: 100%;
    max-height: 100dvh;
    margin: auto 0 0 0;
    border-radius: 22px 22px 0 0;
  }
  .reg-modal__inner {
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  }
  /* Evita auto-zoom forçado do iOS Safari ao tocar nos campos */
  .reg__input { font-size: 16px; }
  .reg-preview-bar select { font-size: 16px; max-width: 190px; }
}

/* ---------- Barra de Prévia Visual (somente em localhost sem chaves) ---------- */
.reg-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: -6px -6px 16px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(245, 179, 1, .12);
  border: 1px solid rgba(245, 179, 1, .35);
  font-size: .74rem;
  color: #ffd666;
}
.reg-preview-bar[hidden] { display: none; }
.reg-preview-bar__tag {
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-size: .66rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(245, 179, 1, .22);
  color: #ffe28a;
}
.reg-preview-bar__sel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.reg-preview-bar select {
  max-width: 230px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(245, 179, 1, .4);
  background: #081321;
  color: var(--text);
  font: inherit;
  font-size: .74rem;
  cursor: pointer;
}

/* ---------- Cabeçalho e Stepper ---------- */
.reg__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.reg__brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.reg__badge {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
  color: var(--brand-2);
  background: rgba(var(--glow-a), .12);
  border: 1px solid rgba(var(--glow-b), .28);
}

.reg__steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 22px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
  border: 1px solid var(--line);
}
.reg__steps[hidden] { display: none; }
.reg__steps li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  opacity: .55;
  transition: opacity .25s, color .25s;
}
.reg__steps li span {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .7rem;
  font-weight: 800;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .03);
}
.reg__steps li small {
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reg__steps li.is-active {
  opacity: 1;
  color: var(--text);
}
.reg__steps li.is-active span {
  background: var(--brand-grad);
  color: var(--on-brand);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(var(--glow-a), .6);
}
.reg__steps li.is-done {
  opacity: .9;
  color: var(--brand-2);
}
.reg__steps li.is-done span {
  background: rgba(var(--glow-a), .18);
  border-color: rgba(var(--glow-b), .45);
  color: var(--brand-2);
}
@media (max-width: 420px) {
  .reg__steps li small { display: none; }
  .reg__steps li { justify-content: center; }
}

.reg__intro { margin-bottom: 18px; }
.reg__title {
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.reg__sub {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}
.reg__sub:empty { display: none; }

/* ---------- Corpo & Formulários ---------- */
.reg__body { min-height: 130px; }
.reg__loading {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  min-height: 150px;
  color: var(--muted);
  font-size: .86rem;
}
.reg__spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(var(--glow-a), .18);
  border-top-color: var(--brand-2);
  animation: tg-spin .8s linear infinite;
}

.reg__form { display: grid; gap: 15px; }
.reg__label {
  display: grid;
  gap: 7px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.reg__field {
  position: relative;
  display: flex;
  align-items: center;
}
.reg__input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(3, 9, 17, .65);
  color: var(--text);
  font: inherit;
  font-size: .98rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.reg__input::placeholder {
  color: rgba(157, 176, 192, .45);
  font-weight: 500;
}
.reg__input:focus {
  outline: none;
  border-color: var(--brand);
  background: rgba(6, 16, 29, .9);
  box-shadow: 0 0 0 3px rgba(var(--glow-a), .18);
}
.reg__input--code {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: .28em;
  font-variant-numeric: tabular-nums;
}
.reg__field .reg__input { padding-right: 46px; }
.reg__eye {
  position: absolute;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.reg__eye:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.reg__eye svg { width: 18px; height: 18px; }

/* Regras visuais da senha (6–16 caracteres + letra e número) */
.reg__rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -4px;
}
.reg__rule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  transition: color .2s, border-color .2s, background .2s;
}
.reg__rule::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}
.reg__rule.is-ok {
  color: #6dffb0;
  background: rgba(109, 255, 176, .09);
  border-color: rgba(109, 255, 176, .32);
}
.reg__rule.is-ok::before { opacity: 1; box-shadow: 0 0 6px currentColor; }

/* Checkbox de Termos e Privacidade (Seção 9) */
.reg__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--line);
  font-size: .78rem;
  line-height: 1.45;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  cursor: pointer;
}
.reg__check input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--brand);
}
.reg__check a {
  color: var(--brand-2);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.reg__check a:hover { color: #fff; }

/* Mensagens de erro mapeadas pelo code (Seção 5.1) */
.reg__error {
  color: #ff9aa6;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.45;
  background: rgba(255, 72, 96, .12);
  border: 1px solid rgba(255, 105, 124, .32);
  border-radius: 11px;
  padding: 11px 14px;
}
.reg__error[hidden] { display: none; }

.reg__submit {
  width: 100%;
  text-align: center;
  border: 0;
  cursor: pointer;
  padding: 14px 24px;
  font-size: .95rem;
}
.reg__submit:disabled,
.reg__form button:disabled,
.reg__msg button:disabled {
  opacity: .52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  animation: none;
}

.reg__actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}
.reg__actions .btn--ghost,
.reg__resend {
  box-shadow: none;
  animation: none;
  cursor: pointer;
}
.reg__resend { width: 100%; }

/* ---------- Telas de estado (Atalho CPF, Handoff, Lojas, Indisponível) ---------- */
.reg__msg {
  display: grid;
  gap: 14px;
  text-align: center;
}
.reg__status-pill {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6dffb0;
  background: rgba(109, 255, 176, .1);
  border: 1px solid rgba(109, 255, 176, .3);
}
.reg__status-pill.is-pending {
  color: #ffd166;
  background: rgba(255, 209, 102, .12);
  border-color: rgba(255, 209, 102, .35);
}
.reg__email-card {
  padding: 13px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line-strong);
  display: grid;
  gap: 3px;
}
.reg__email-card small {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.reg__email-card strong {
  color: var(--brand-2);
  font-size: .98rem;
  word-break: break-all;
}
.reg__hint {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.5;
}
.reg__stores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.reg__stores .store {
  justify-content: center;
  padding: 10px 12px;
  font-size: .9rem;
}

/* ---------- Depósito Pix (Seção 4.11) ---------- */
.reg__presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.reg__preset {
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.reg__preset:hover,
.reg__preset.is-active {
  border-color: var(--brand);
  background: rgba(var(--glow-a), .15);
  color: var(--brand-2);
}
.reg__pix {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 16px;
  border: 1px solid rgba(var(--glow-b), .28);
  border-radius: 14px;
  background: rgba(4, 13, 24, .75);
  text-align: center;
}
.reg__pix[hidden] { display: none; }
.reg__pix-qr {
  width: 188px;
  height: 188px;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .8);
}
.reg__pix-qr img,
.reg__pix-qr svg { width: 100%; height: 100%; display: block; }
.reg__pixcode {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .7rem;
  word-break: break-all;
  color: var(--muted);
  background: rgba(0, 0, 0, .45);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 9px;
  width: 100%;
  max-height: 68px;
  overflow-y: auto;
  text-align: left;
}
.reg__pix-copy { width: 100%; }

.reg__turnstile { min-height: 0; }
.reg__foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: .74rem;
}
.reg__lock { width: 15px; height: 15px; color: var(--brand-2); display: inline-flex; }
.reg__lock svg { width: 100%; height: 100%; }

@media (max-width: 480px) {
  .reg__actions { grid-template-columns: 1fr; }
  .reg__actions .btn--ghost { order: 2; }
}

/* ---------- Banner LGPD de consentimento de cookies/pixel (Seção 9) ---------- */
.consent {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 20px;
  z-index: 90;
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 16px;
  background:
    linear-gradient(rgba(7, 17, 30, .95), rgba(7, 17, 30, .95)) padding-box,
    linear-gradient(155deg, rgba(220, 240, 255, .24), rgba(var(--glow-b), .35)) border-box;
  border: 1px solid transparent;
  backdrop-filter: blur(16px);
  color: var(--text);
  box-shadow: 0 24px 54px -16px rgba(0, 0, 0, .92);
  font-size: .85rem;
}
.consent__text { margin: 0; flex: 1 1 240px; color: var(--muted); line-height: 1.45; }
.consent__text strong { color: var(--text); }
.consent__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.consent .btn { margin-top: 0; padding: 9px 18px; animation: none; cursor: pointer; border: 0; }
.consent .btn--ghost { border: 1px solid rgba(var(--glow-a), .5); }
@media (max-width: 720px) {
  .consent { bottom: 84px; }
}

/* Faixa superior caso ?mock=1 explícito seja usado na URL */
.mock-banner {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 95;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(245, 179, 1, .94);
  color: #1a1200;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .03em;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .7);
}
