:root {
  --mammi-purple: #7736D4;
  --mammi-purple-dark: #5b22a8;
  --mammi-purple-soft: #f4eafe;
  --mammi-pink: #ff7eb6;
  --ink-900: #1a1230;
  --ink-700: #4a3f63;
  --ink-500: #7a7191;
  --ink-300: #cdc5dd;
  --bg: #fbf9ff;
  --card: #ffffff;
  --success: #1c9468;
  --warn: #c47a00;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(26, 18, 48, 0.06);
  --shadow-md: 0 8px 24px rgba(119, 54, 212, 0.10);
  --shadow-lg: 0 24px 64px rgba(119, 54, 212, 0.18);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

a { color: var(--mammi-purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.hero {
  text-align: center;
  padding: 32px 0 24px;
}

.logo {
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--mammi-purple) 0%, var(--mammi-pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.tagline {
  color: var(--ink-500);
  font-size: 14px;
  margin-top: 4px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
  margin-top: 24px;
}

.card-pop {
  background: linear-gradient(180deg, #fff 0%, #faf6ff 100%);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  margin-top: 28px;
  position: relative;
  overflow: hidden;
}

.card-pop::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(119, 54, 212, 0.12) 0%, transparent 70%);
  border-radius: 50%;
}

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--mammi-purple);
  margin-bottom: 6px;
}

.title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink-900);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 15px;
  color: var(--ink-700);
  margin-bottom: 20px;
}

/* Descrição do formulário público preserva as quebras de linha digitadas no
   builder (textContent traz os \n, mas white-space:normal os colapsaria). */
#form-desc {
  white-space: pre-line;
}

.greeting {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.greeting .name {
  background: linear-gradient(135deg, var(--mammi-purple) 0%, var(--mammi-pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--mammi-purple-soft);
}

.row:first-of-type { border-top: none; }

.row-label {
  font-size: 13px;
  color: var(--ink-500);
  flex: 0 0 88px;
}

.row-value {
  font-size: 15px;
  color: var(--ink-900);
  font-weight: 600;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  margin-top: 12px;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--mammi-purple) 0%, var(--mammi-purple-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(119, 54, 212, 0.32);
}

.btn-primary:hover { box-shadow: 0 10px 24px rgba(119, 54, 212, 0.4); text-decoration: none; }

.btn-secondary {
  background: var(--mammi-purple-soft);
  color: var(--mammi-purple);
}

.btn-secondary:hover { background: #ebd9fb; text-decoration: none; }

.store-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.store-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.store-btn:hover { background: #2c1f4d; text-decoration: none; }
.store-btn small { display: block; font-size: 10px; font-weight: 400; opacity: 0.7; line-height: 1; }
.store-btn span { display: block; line-height: 1.2; text-align: left; }

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--mammi-purple-soft);
  border-top-color: var(--mammi-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.center { text-align: center; }
.muted { color: var(--ink-500); font-size: 13px; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-top: 16px;
  font-size: 14px;
}

.alert-warn {
  background: #fff5e1;
  color: #7a4a00;
  border: 1px solid #ffd99a;
}

.alert-danger {
  background: #ffeceb;
  color: #7a1c19;
  border: 1px solid #f7c2bf;
}

.divider {
  height: 1px;
  background: var(--mammi-purple-soft);
  margin: 20px 0;
}

.footer {
  text-align: center;
  margin-top: 32px;
  font-size: 12px;
  color: var(--ink-500);
}

.footer a { color: var(--ink-500); text-decoration: underline; }

.feature-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--ink-700);
}

.feature-list .check {
  flex: 0 0 24px;
  height: 24px;
  background: var(--mammi-purple-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mammi-purple);
  font-weight: 700;
  font-size: 14px;
}

.hidden { display: none !important; }

/* Logo da agência no topo do form (substitui o branding MammiHub quando
   agency_logo_url vem no payload). Empilha sobre o nome da agência. */
.agency-logo {
  display: block;
  max-width: 220px;
  max-height: 80px;
  object-fit: contain;
  margin: 0 auto 8px;
}

/* Cover image (capa estilo Google Forms) — quebra o padding do .card */
.form-cover {
  display: block;
  width: calc(100% + 48px);
  margin: -28px -24px 20px;
  max-height: 180px;
  object-fit: cover;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

/* Seção do formulário (divisor visual estilo Google Forms) */
.field-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--mammi-purple-soft);
}

.form-section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--ink-900);
}

.form-section-desc {
  font-size: 13px;
  color: var(--ink-500);
  margin-top: 4px;
}

/* Campo de upload de arquivo */
.file-upload-input { display: none; }

.file-upload-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px dashed var(--ink-300);
  border-radius: var(--radius-md);
  background: var(--mammi-purple-soft);
  color: var(--mammi-purple);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.file-upload-trigger:hover { border-color: var(--mammi-purple); background: #ebd9fb; }
.file-upload-trigger.field-error { border-color: var(--danger) !important; }

.file-upload-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-700);
}

.file-upload-status.uploading { color: var(--ink-500); }
.file-upload-status.success { color: var(--success); }
.file-upload-status.error { color: var(--danger); }

.file-upload-status .file-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-status .file-action {
  flex: 0 0 auto;
  color: var(--mammi-purple);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.file-upload-status .mini-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--mammi-purple-soft);
  border-top-color: var(--mammi-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

/* Descrição do campo (help renderizado como descrição abaixo do label).
   Seletor com .field para vencer o .field-help inline dos HTMLs. */
.field .field-desc {
  margin-top: -2px;
  margin-bottom: 8px;
}

/* ─── Navegação multi-etapas (estilo Google Forms) ─────────────────── */
.form-nav { margin-top: 8px; }

.form-progress {
  margin-bottom: 16px;
}

.form-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  margin-bottom: 6px;
  text-align: right;
}

.form-progress-bar {
  height: 6px;
  background: var(--mammi-purple-soft);
  border-radius: 999px;
  overflow: hidden;
}

.form-progress-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--mammi-purple) 0%, var(--mammi-pink) 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
  min-width: 6px;
}

.form-nav-buttons {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.form-nav-buttons .btn { margin-top: 0; }

/* Voltar mais discreto, Próximo/Enviar com mais peso */
.form-nav-back { flex: 0 0 38%; }
.form-nav-next,
.form-nav-buttons #submit-btn { flex: 1 1 auto; }

/* ─── Campo de endereço (grid estilo Google Forms) ─────────────────── */
.address-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.address-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* campos que ocupam a linha inteira */
.address-cell-cep,
.address-cell-street,
.address-cell-complement,
.address-cell-neighborhood {
  grid-column: 1 / -1;
}

/* número e UF estreitos, cidade do lado */
.address-cell-number { grid-column: 1 / 2; }
.address-cell-city { grid-column: 1 / 2; }
.address-cell-state { grid-column: 2 / 3; }

.address-sublabel {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
}

.address-box input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink-900);
  background: #fff;
}

.address-box input[type="text"]:focus {
  outline: none;
  border-color: var(--mammi-purple);
  box-shadow: 0 0 0 3px rgba(119, 54, 212, 0.12);
}

.address-box input.field-error { border-color: var(--danger) !important; }

.addr-cep-status {
  font-size: 11px;
  margin-top: 2px;
  min-height: 14px;
}

.addr-cep-status.loading { color: var(--ink-500); }
.addr-cep-status.warn { color: var(--warn); }

@media (min-width: 600px) {
  .container { max-width: 540px; }
  .greeting { font-size: 32px; }
}

/* Rodapé "Desenvolvido por MammiHub" nos formulários públicos.
   Agência fica em destaque no header; a marca MammiHub vem discreta no pé. */
.made-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 12px;
}
.made-by span { font-size: 12px; color: var(--ink-500); }
.made-by img { height: 18px; width: auto; opacity: 0.85; display: block; }

/* ─── Aviso de rascunho recuperado (form.js / cadastro.js) ───────────── */
.draft-restored {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: var(--mammi-purple-soft);
  border: 1px solid #e3d2fb;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-700);
}
.draft-restored span { flex: 1; }
.draft-restored-close {
  flex: none;
  background: transparent;
  border: none;
  color: var(--ink-500);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.draft-restored-close:hover { color: var(--ink-900); }
