/*
 * Onboarding — funil de criação de Loja via convite.
 *
 * Layout fiel ao mockup `docs/screens/onboarding.html`:
 *   - Mobile: coluna única (wordmark + card scrollável)
 *   - ≥700px: card mais largo + fields em grid 2-col
 *   - ≥900px: split layout (painel escuro à esquerda + card à direita)
 *
 * Classes prefixadas `.ob-*` (Onboarding). Stimulus controllers reusados:
 * password-toggle, password-confirm, slug, whatsapp-mask, char-count.
 */

.ob-shell {
  --ob-amber: #FFC233;
  --ob-brand: var(--brand-primary);
  --ob-brand-deep: var(--brand-deep);
  --ob-brand-pale: var(--brand-pale);
  --ob-border-faint: rgba(8, 13, 20, .06);
  --ob-border-soft:  rgba(8, 13, 20, .10);
  --ob-border-strong:rgba(8, 13, 20, .16);

  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--neutral-800);
  background: var(--neutral-50);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
 * SHELL — layout split em ≥900px
 * ========================================================================== */
/* .ob-panel-left { display: none } mobile + display: flex desktop vivem em
 * design_tokens.css junto com o auth-shell — mantém o cascade resolvido. */
.ob-panel-right { width: 100%; }

.ob-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 64px;
}

.ob-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -.04em;
  line-height: 1;
  color: var(--neutral-800);
  margin-bottom: 28px;
  text-align: center;
  text-decoration: none;
}
.ob-wordmark .i   { color: var(--ob-amber); }
.ob-wordmark .dot { color: var(--ob-brand); }

/* ============================================================================
 * CARD container
 * ========================================================================== */
.ob-card {
  width: 100%;
  max-width: 640px;
  /* min-width: 0 explícito pra não respeitar min-content dos descendentes.
   * .ob-page é flex column align-items: center, então width: 100% já vira
   * cross-axis fill; sem min-width: 0 o card cresce com inputs internos. */
  min-width: 0;
  background: var(--neutral-0);
  border: 1px solid var(--ob-border-faint);
  border-radius: var(--radius-2xl);
  box-shadow: 0 1px 4px rgba(8, 13, 20, .07), 0 4px 16px rgba(8, 13, 20, .04);
  overflow: hidden;
}

.ob-card-head {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--ob-border-faint);
  background: var(--neutral-0);
}
.ob-card-head-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -.03em;
  color: var(--neutral-800);
  margin-bottom: 4px;
}
.ob-card-head-sub {
  font-size: 14px;
  color: var(--neutral-500);
  line-height: 1.5;
}
.ob-card-head-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--neutral-400);
  line-height: 1.4;
  letter-spacing: .01em;
}
.ob-card-head-meta em {
  font-style: normal;
  font-weight: 600;
  color: var(--neutral-500);
}

.ob-card-body { padding: 0; min-width: 0; }

.ob-card-foot {
  padding: 20px 24px;
  border-top: 1px solid var(--ob-border-faint);
  background: var(--neutral-50);
}

/* ============================================================================
 * FLASH (banner de erro inline no card)
 * ========================================================================== */
.ob-flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 24px;
  background: var(--danger-bg);
  border-bottom: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-size: 14px;
  line-height: 1.5;
}
.ob-flash-icon { flex-shrink: 0; margin-top: 1px; }

/* ============================================================================
 * FIELDSET + numbered legend
 * ========================================================================== */
.ob-card fieldset {
  border: none;
  padding: 0;
  margin: 0;
  /* <fieldset> tem min-inline-size: min-content do user-agent. Sem isso, o
   * conteúdo (slug preview "listou.net/...", prefixo +55, etc.) impede o
   * fieldset de encolher no mobile e o grid de swatches acaba renderizado
   * na largura inflada, estourando o card. */
  min-width: 0;
}
.ob-card fieldset + fieldset {
  border-top: 1px solid var(--ob-border-faint);
}

.ob-fieldset-inner { padding: 24px 24px 28px; min-width: 0; }

.ob-fieldset-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.ob-legend-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ob-brand-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ob-brand);
  flex-shrink: 0;
}
.ob-legend-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
  color: var(--neutral-700);
}

/* ============================================================================
 * FIELDS
 * ========================================================================== */
/* min-width: 0 essencial: .ob-field é flex column mas também flex/grid item
 * em outros contextos (.ob-field-row em tablet). Sem isso, conteúdo intrínseco
 * de inputs filhos (size=20 default) empurra a cadeia toda. */
.ob-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ob-field + .ob-field { margin-top: 16px; }

.ob-field-label {
  font-weight: 500;
  font-size: 12px;
  color: var(--neutral-500);
}
.ob-field-label em {
  font-style: normal;
  color: var(--neutral-400);
  font-weight: 400;
}

.ob-field-hint {
  font-size: 12px;
  color: var(--neutral-400);
  margin-top: 4px;
  line-height: 1.5;
}
.ob-field-hint a {
  color: var(--ob-brand);
  font-weight: 500;
  text-decoration: none;
}
.ob-field-hint a:hover { text-decoration: underline; }
.ob-field-hint strong { color: var(--neutral-500); font-weight: 600; }

.ob-field-err {
  font-size: 12px;
  color: var(--danger-solid);
  margin-top: 3px;
}

/* Feedback inline de validação Stimulus (genérico — usado por email-validate
 * e qualquer controller futuro que siga o padrão). Esconde por default; o
 * controller adiciona `.is-shown` + variante semântica. */
.ob-field-feedback {
  font-size: 12px;
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 5px;
}
.ob-field-feedback.is-shown { display: inline-flex; }
.ob-field-feedback.is-bad   { color: var(--danger-text); }
.ob-field-feedback.is-bad::before { content: "✗"; font-weight: 700; }

/* ============================================================================
 * INPUTS
 * ========================================================================== */
.ob-input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--neutral-800);
  background: var(--neutral-0);
  border: 1px solid var(--ob-border-soft);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 120ms var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.ob-input::placeholder { color: var(--neutral-300); }
.ob-input:hover { border-color: var(--ob-border-strong); }
.ob-input:focus {
  border: 2px solid var(--ob-brand);
  padding: 0 11px;
  box-shadow: 0 0 0 3px rgba(0, 16, 254, .10);
}
.ob-input.is-err {
  border: 2px solid var(--danger-solid);
  padding: 0 11px;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .10);
}
.ob-input:disabled {
  background: var(--neutral-50);
  color: var(--neutral-400);
  cursor: not-allowed;
}

/* Password toggle wrapper */
.ob-pw-wrap { position: relative; min-width: 0; }
.ob-pw-wrap .ob-input { padding-right: 46px; }
.ob-pw-wrap .ob-input:focus,
.ob-pw-wrap .ob-input.is-err { padding-right: 45px; }
.ob-pw-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--neutral-400);
  transition: color 120ms var(--ease-out);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.ob-pw-btn::before {
  /* expande hit area pra ≥44×44 sem mudar o visual (WCAG 2.5.5) */
  content: "";
  position: absolute;
  inset: -10px;
}
.ob-pw-btn:hover { color: var(--neutral-600); }
.ob-pw-btn:focus-visible {
  outline: 2px solid var(--ob-brand);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Prefix input wrapper (listou.net/... e +55 ...) */
.ob-prefix-wrap {
  display: flex;
  align-items: center;
  /* min-width: 0 essencial: o wrap é flex-container mas também flex-item do
   * .ob-field (display: flex column). Sem isso, o min-content do <input>
   * (size=20 default) impede o wrap de encolher e estoura o card. */
  min-width: 0;
  border: 1px solid var(--ob-border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 120ms var(--ease-out);
  background: var(--neutral-0);
}
.ob-prefix-wrap:focus-within {
  border: 2px solid var(--ob-brand);
  box-shadow: 0 0 0 3px rgba(0, 16, 254, .10);
}
.ob-prefix-wrap.is-err {
  border: 2px solid var(--danger-solid);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .10);
}

.ob-input-prefix {
  flex-shrink: 0;
  height: 48px;
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-400);
  background: var(--neutral-50);
  border-right: 1px solid var(--ob-border-soft);
  white-space: nowrap;
  user-select: none;
}
/* Sufixo do modo subdomínio (ADR-0031): mesmo visual do prefixo, borda no
 * outro lado — a ordem no DOM (depois do input) posiciona via flex. */
.ob-input-prefix.is-suffix {
  border-right: none;
  border-left: 1px solid var(--ob-border-soft);
  padding: 0 12px 0 10px;
}
.ob-input-prefixed {
  flex: 1;
  height: 48px;
  padding: 0 12px;
  font-size: 16px;
  font-family: var(--font-mono);
  color: var(--neutral-800);
  background: transparent;
  border: none;
  outline: none;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.ob-input-prefixed::placeholder {
  color: var(--neutral-300);
  font-family: var(--font-body);
}

/* Textarea */
.ob-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--neutral-800);
  background: var(--neutral-0);
  border: 1px solid var(--ob-border-soft);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  line-height: 1.55;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 120ms var(--ease-out);
}
.ob-textarea::placeholder { color: var(--neutral-300); }
.ob-textarea:hover { border-color: var(--ob-border-strong); }
.ob-textarea:focus {
  border: 2px solid var(--ob-brand);
  padding: 9px 11px;
  box-shadow: 0 0 0 3px rgba(0, 16, 254, .10);
}

/* Char count */
.ob-char-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--neutral-400);
  text-align: right;
  margin-top: 4px;
}
.ob-char-count.is-near { color: var(--warning-text); }

/* ============================================================================
 * SLUG feedback (preview + badge — Stimulus controller `slug`)
 * ========================================================================== */
.ob-slug-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--neutral-400);
  margin-top: 6px;
  line-height: 1.5;
}
.ob-slug-preview .text-slate-400 { color: var(--neutral-300); }

.ob-slug-spinner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--neutral-400);
}
.ob-slug-spinner[hidden] { display: none; }

.ob-spin {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ob-spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes ob-spin { to { transform: rotate(360deg); } }

/* Badge de resultado da verificação de slug — classes vêm do slug_controller. */
.ob-slug-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 9999px;
  border: 1px solid transparent;
}
.ob-slug-badge.is-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.ob-slug-badge.is-error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.ob-slug-badge.is-neutral { background: var(--neutral-100); border-color: var(--ob-border-faint); color: var(--neutral-600); }
.ob-slug-badge.is-success::before { content: "✓ "; }
.ob-slug-badge.is-error::before   { content: "✗ "; }
.ob-slug-badge[hidden] { display: none; }

/* ============================================================================
 * PASSWORD CONFIRM feedback (Stimulus controller `password-confirm`)
 * ========================================================================== */
.ob-pw-confirm-feedback {
  font-size: 12px;
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 5px;
}
.ob-pw-confirm-feedback.is-shown { display: inline-flex; }
.ob-pw-confirm-feedback.is-ok    { color: var(--success-text); }
.ob-pw-confirm-feedback.is-bad   { color: var(--danger-text); }
.ob-pw-confirm-feedback.is-ok::before  { content: "✓"; font-weight: 700; }
.ob-pw-confirm-feedback.is-bad::before { content: "✗"; font-weight: 700; }

/* ============================================================================
 * COLOR SWATCHES (radio buttons visuais)
 * ========================================================================== */
.ob-swatches {
  display: grid;
  /* minmax(0, 1fr) em vez de 1fr puro: 1fr expande até min-content dos children,
   * o que em viewports estreitos faz o grid estourar a fieldset por causa do
   * aspect-ratio + border dos swatch-btn. minmax(0, 1fr) permite encolher até 0. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ob-swatch-item { position: relative; min-width: 0; }
.ob-swatch-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ob-swatch-btn {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  position: relative;
}
.ob-swatch-btn:hover { transform: scale(1.07); }
.ob-swatch-radio:checked + .ob-swatch-btn {
  border-color: var(--neutral-800);
  box-shadow: 0 0 0 3px rgba(8, 13, 20, .12);
  transform: scale(1.07);
}
.ob-swatch-radio:focus-visible + .ob-swatch-btn {
  outline: 2px solid var(--ob-brand);
  outline-offset: 4px;
}
.ob-swatch-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms var(--ease-out);
}
.ob-swatch-radio:checked + .ob-swatch-btn .ob-swatch-check { opacity: 1; }

/* ============================================================================
 * CHECKBOX customizado (Aceite dos termos)
 * ========================================================================== */
.ob-check-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.ob-check-input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1.5px solid var(--ob-border-strong);
  border-radius: 4px;
  background: var(--neutral-0);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms var(--ease-out), border-color 120ms var(--ease-out);
  position: relative;
}
.ob-check-input:checked {
  background: var(--ob-brand);
  border-color: var(--ob-brand);
}
.ob-check-input:checked::after {
  content: '';
  display: block;
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
.ob-check-input:focus-visible {
  outline: 2px solid var(--ob-brand);
  outline-offset: 2px;
}
.ob-check-text {
  font-size: 14px;
  color: var(--neutral-600);
  line-height: 1.5;
}
.ob-check-text a {
  color: var(--ob-brand);
  font-weight: 500;
  text-decoration: none;
}
.ob-check-text a:hover { text-decoration: underline; }

/* ============================================================================
 * SUBMIT button + back link
 * ========================================================================== */
.ob-btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -.01em;
  background: var(--ob-brand);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: background 120ms var(--ease-out), transform 100ms var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.ob-btn-submit:hover  { background: var(--ob-brand-deep); }
.ob-btn-submit:active { transform: scale(.98); }
.ob-btn-submit:focus-visible {
  outline: 2px solid var(--ob-brand);
  outline-offset: 2px;
}

.ob-back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-400);
  text-decoration: none;
  transition: color 120ms var(--ease-out);
}
.ob-back-link:hover { color: var(--neutral-700); }
.ob-back-link:focus-visible {
  outline: 2px solid var(--ob-brand);
  outline-offset: 3px;
  border-radius: 4px;
  color: var(--neutral-700);
}

/* ============================================================================
 * TABLET ≥ 700px — card mais largo, fields em grid 2-col
 * ========================================================================== */
@media (min-width: 700px) {
  .ob-page { padding: 48px 24px 80px; }
  .ob-wordmark { font-size: 32px; margin-bottom: 32px; }
  .ob-card-head { padding: 32px 32px 28px; }
  .ob-card-head-title { font-size: 26px; }
  .ob-fieldset-inner { padding: 28px 32px 32px; }
  .ob-card-foot { padding: 24px 32px; }
  .ob-swatches { grid-template-columns: repeat(8, minmax(0, 1fr)); }

  .ob-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .ob-field-row .ob-field { margin-top: 0; }
}

/* ============================================================================
 * DESKTOP ≥ 900px — split (left panel + right scroll)
 * ========================================================================== */
@media (min-width: 900px) {
  /* O bg escuro vai no shell, não no body — evita vazar pras outras telas
   * que carregam o mesmo CSS (dashboard, login, etc.). */
  .ob-shell { display: flex; min-height: 100vh; background: var(--neutral-900); }

  /* Painel esquerdo (.ob-panel-left) + filhos (wordmark/tag/steps/footer)
   * estilizados em design_tokens.css junto com .auth-shell__*. */

  .ob-panel-right {
    flex: 1;
    background: var(--neutral-50);
    overflow-y: auto;
  }

  .ob-page {
    min-height: 100vh;
    justify-content: flex-start;
    padding: 48px 32px 80px;
  }

  /* mobile wordmark some — desktop tem o do painel esquerdo */
  .ob-wordmark { display: none; }
}
