/* Form Engine - Estilos do formulário uma-pergunta-por-tela */
/* Responsivo: PC e Mobile */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
}

:root {
  --form-bg: #0f0f12;
  --form-primary: #6366f1;
  --form-secondary: #818cf8;
  --form-text: #fafafa;
  --form-text-muted: #a1a1aa;
  --form-font: 'Inter', system-ui, -apple-system, sans-serif;
  --form-overlay: rgba(0,0,0,0.4);
  --form-safe-top: env(safe-area-inset-top, 0);
  --form-safe-bottom: env(safe-area-inset-bottom, 0);
  --form-safe-left: env(safe-area-inset-left, 0);
  --form-safe-right: env(safe-area-inset-right, 0);
}

/* Camada de BG injetada via JS (mais confiável em dispositivos móveis que CSS background-image) */
.form-bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.form-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
/* Overlay (sombra da imagem) - aplicado sobre a imagem de fundo */
.form-bg-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--form-overlay, rgba(0,0,0,0.5));
  pointer-events: none;
}
/* Vignette (bordas escuras) */
.form-bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 200px 100px var(--form-bg-shadow, rgba(0,0,0,0.35));
  pointer-events: none;
}
/* Mobile: mostra IMG_8882, esconde IMG_9588 */
.form-bg-desktop { display: none !important; }
@media screen and (min-width: 769px) {
  .form-bg-mobile { display: none !important; }
  .form-bg-desktop { display: block !important; }
}
.form-page {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  background: var(--form-bg);
  color: var(--form-text);
  font-family: var(--form-font);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: max(1rem, var(--form-safe-top));
  padding-bottom: max(1rem, var(--form-safe-bottom));
  padding-left: max(1rem, var(--form-safe-left));
  padding-right: max(1rem, var(--form-safe-right));
  position: relative;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Elementos visíveis sobre BG (quando cliente define backgroundImage no config) */
.form-page.form--has-bg-image .form-card {
  background: rgba(10,10,14,0.9);
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.form-page.form--has-bg-image .form-title,
.form-page.form--has-bg-image .form-subtitle {
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.form-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.form-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.form-logo {
  max-height: 60px;
  max-width: 100%;
  margin-bottom: 1rem;
  display: none;
  object-fit: contain;
}

.form-title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--form-text);
  line-height: 1.3;
  word-wrap: break-word;
}

.form-subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: var(--form-text-muted);
  margin: 0;
  line-height: 1.4;
}

.form-progress-wrap {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  position: relative;
}

.form-step {
  display: block;
  font-size: 0.8rem;
  color: var(--form-text-muted);
  text-align: right;
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

.form-progress {
  height: 100%;
  background: var(--form-primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.35s ease;
}

.form-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  box-sizing: border-box;
}

.form-field {
  margin-bottom: 0;
}

.form-field label,
.form-field__label {
  display: block;
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--form-text);
  line-height: 1.4;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field textarea,
.form-field select {
  width: 100%;
  min-width: 0;
  padding: 0.875rem 1rem;
  font-size: 16px;
  font-family: inherit;
  color: var(--form-text);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

/* Evita zoom no iOS ao focar em input */
@media screen and (max-width: 768px) {
  .form-field input[type="text"],
  .form-field input[type="email"],
  .form-field input[type="tel"],
  .form-field input[type="number"],
  .form-field textarea,
  .form-field select {
    font-size: 16px !important;
  }
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--form-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--form-text-muted);
  opacity: 0.7;
}

.form-field textarea {
  min-height: 100px;
  resize: vertical;
}

.form-field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-radio-group,
.form-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-radio-option,
.form-checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  min-height: 48px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.form-radio-option:hover,
.form-checkbox-option:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
}

.form-radio-option input:checked + *,
.form-radio-option:has(input:checked),
.form-checkbox-option:has(input:checked) {
  border-color: var(--form-primary);
  background: rgba(99,102,241,0.15);
}

.form-radio-option input,
.form-checkbox-option input {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  accent-color: var(--form-primary);
  flex-shrink: 0;
  cursor: pointer;
}

.form-start-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}
.form-btn--iniciar {
  margin-left: 0;
  min-width: 200px;
}

.form-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-btn {
  padding: 0.875rem 1.25rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex: 1;
  min-width: 120px;
}

.form-btn:active {
  transform: scale(0.98);
}

.form-btn--prev {
  background: rgba(255,255,255,0.1);
  color: var(--form-text);
  visibility: hidden;
}

.form-btn--prev:hover {
  background: rgba(255,255,255,0.15);
}

.form-btn--next {
  background: var(--form-primary);
  color: white;
  margin-left: auto;
}

.form-btn--next:hover:not(:disabled) {
  background: var(--form-secondary);
}

.form-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.form-thankyou {
  text-align: center;
  padding: clamp(1rem, 3vw, 1.5rem) 0;
}

.form-thankyou__title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--form-text);
}

.form-thankyou__msg {
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  color: var(--form-text-muted);
  margin: 0;
  line-height: 1.6;
}

/* ===== Mobile - scroll permitido, proporções ajustadas ===== */
@media screen and (max-width: 768px) {
  html, body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .form-page {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: flex-start;
    padding-bottom: 2rem;
  }

  .form-page .form-bg-layer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
  }

  .form-page {
    background-color: #000;
  }
  .form-container {
    z-index: 1;
    flex: 1;
    min-height: 0;
  }
  .form-title,
  .form-subtitle,
  .form-step {
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  }
  .form-field label,
  .form-field__label {
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  }
  .form-card {
    background: rgba(10,10,14,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  }
  .form-field input[type="text"],
  .form-field input[type="email"],
  .form-field input[type="tel"],
  .form-field input[type="number"],
  .form-field textarea,
  .form-field select {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
  }
  .form-progress-wrap {
    background: rgba(255,255,255,0.2);
  }
  .form-radio-option,
  .form-checkbox-option {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.18);
  }

  /* Checkboxes em 2 colunas em mobile */
  .form-checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .form-checkbox-option {
    padding: 0.6rem 0.75rem;
    min-height: 42px;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .form-checkbox-option input {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
  }
}

/* ===== Celulares menores - etapa 5 compacta, botão sempre visível ===== */
@media screen and (max-width: 480px) {
  .form-page {
    padding: 0.75rem;
    padding-top: max(0.75rem, var(--form-safe-top));
    padding-bottom: max(2rem, var(--form-safe-bottom));
    padding-left: max(0.75rem, var(--form-safe-left));
    padding-right: max(0.75rem, var(--form-safe-right));
    align-items: flex-start;
    padding-top: max(1rem, var(--form-safe-top));
  }

  .form-header {
    margin-bottom: 1rem;
  }

  .form-progress-wrap {
    margin-bottom: 0.25rem;
  }

  .form-step {
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
  }

  .form-card {
    padding: 1rem;
    border-radius: 12px;
  }

  /* Celulares muito pequenos: checkboxes ainda mais compactos */
  .form-checkbox-group {
    gap: 0.4rem;
  }

  .form-checkbox-option {
    padding: 0.5rem 0.6rem;
    min-height: 38px;
    font-size: 0.85rem;
  }

  .form-field__label {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  .form-radio-group {
    gap: 0.4rem;
  }

  .form-radio-option {
    padding: 0.5rem 0.6rem;
    min-height: 40px;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .form-radio-option input {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
  }

  .form-nav {
    flex-direction: column;
    margin-top: 1rem;
    gap: 0.5rem;
  }

  .form-btn {
    width: 100%;
    min-width: 100%;
    padding: 0.875rem 1rem;
    min-height: 44px;
  }

  .form-btn--prev {
    order: 2;
  }

  .form-btn--next {
    order: 1;
    margin-left: 0;
  }
}

/* Tablet e telas médias */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .form-page {
    padding: 1.25rem;
  }

  .form-container {
    max-width: 100%;
  }
}

/* Desktop - base */
@media screen and (min-width: 769px) {
  html, body {
    overflow-y: auto;
  }

  .form-page {
    padding: 2rem 1.5rem;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
    padding-top: max(2rem, var(--form-safe-top));
    padding-bottom: max(2rem, var(--form-safe-bottom));
  }

  .form-container {
    z-index: 1;
    max-width: min(520px, 90vw);
    margin: 0 auto;
    flex-shrink: 0;
  }

  .form-title {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
  }

  .form-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    max-width: 42ch;
    margin-left: auto;
    margin-right: auto;
  }

  .form-title,
  .form-subtitle,
  .form-step {
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  }

  .form-field label,
  .form-field__label {
    font-size: 1.125rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  }

  .form-card {
    background: rgba(10,10,14,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    padding: 2rem;
  }

  .form-btn {
    min-width: 140px;
  }
}

/* Desktop - telas grandes (1024px+) */
@media screen and (min-width: 1024px) {
  .form-page {
    padding: 3rem 2rem;
  }

  .form-container {
    max-width: 560px;
  }

  .form-card {
    padding: 2.25rem;
  }
}

/* Desktop - telas extra grandes (1440px+) */
@media screen and (min-width: 1440px) {
  .form-page {
    padding: 4rem 3rem;
  }

  .form-container {
    max-width: 580px;
  }

  .form-card {
    padding: 2.5rem;
  }
}
