/* ==========================================================================
   DESIGN FORMULÁRIO DE CADASTRO WHATSAPP (TEMA APPLE WHITE & BOTÃO VERDE)
   Fundo Branco, Tipografia Nítida, Busca de UF & Cidade
   ========================================================================== */

:root {
  --apple-bg: #f5f5f7;
  --card-bg: #ffffff;
  --input-bg: #fbfbfd;
  --input-focus-bg: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-label: #424245;
  --border-light: rgba(0, 0, 0, 0.12);
  --border-focus: #25d366;
  
  --tag-green: #128c40;
  --tag-bg: rgba(37, 211, 102, 0.12);
  
  --wpp-green: #25d366;
  --wpp-green-dark: #128c40;
  --btn-green-gradient: linear-gradient(180deg, #27dc6a 0%, #1fbe5b 100%);
  --btn-green-glow: rgba(37, 211, 102, 0.38);
  
  --danger-color: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.08);
  
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  font-family: var(--font-stack);
  background-color: var(--apple-bg);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  overflow-x: hidden;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
}

/* Fundo Iluminado Sutil Estilo Apple */
.page-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, rgba(37, 211, 102, 0.07) 0%, rgba(245, 245, 247, 0) 65%);
  pointer-events: none;
  z-index: 0;
}

/* Container Principal */
.page-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* Card Apple Branco Minimalista */
.form-modal-card {
  position: relative;
  background: var(--card-bg);
  border-radius: 28px;
  padding: 38px 28px 32px;
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.08),
              0 1px 3px rgba(0, 0, 0, 0.04),
              0 0 0 1px var(--border-light);
}

/* Botão Fechar (X) */
.btn-close-modal {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-close-modal svg {
  width: 15px;
  height: 15px;
}

.btn-close-modal:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Tag Superior em Destaque */
.top-tag {
  color: var(--tag-green);
  background: var(--tag-bg);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
  display: inline-block;
}

/* Cabeçalho */
.card-header {
  margin-bottom: 24px;
}

.main-title {
  font-size: 1.62rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
  font-weight: 400;
}

/* Formulário e Campos */
.lead-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-group input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-light);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.form-group input::placeholder {
  color: #9ca3af;
}

.form-group input:focus {
  border-color: var(--wpp-green);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

.form-group.has-error input,
.form-group.has-error .select-trigger {
  border-color: var(--danger-color);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.field-error {
  display: none;
  font-size: 0.74rem;
  color: var(--danger-color);
  font-weight: 500;
  margin-top: 2px;
}

.form-group.has-error .field-error {
  display: block;
}

/* Linha Estado & Cidade */
.form-row-location {
  display: flex;
  gap: 12px;
}

.group-uf {
  width: 110px;
  flex-shrink: 0;
}

.group-cidade {
  flex: 1;
}

/* ==========================================================================
   SELECTS COM BUSCA INSTANTÂNEA (ESTADO & CIDADE)
   ========================================================================== */
.searchable-select {
  position: relative;
  width: 100%;
}

.select-trigger {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: var(--transition);
}

.select-trigger:focus,
.select-trigger.is-active {
  border-color: var(--wpp-green);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

.select-trigger.is-disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.02);
}

.trigger-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 6px;
}

.trigger-text.is-placeholder {
  color: #9ca3af;
}

.select-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.select-trigger.is-active .select-chevron {
  transform: rotate(180deg);
}

/* Popover do Dropdown */
.select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.18),
              0 0 0 1px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  padding: 8px;
  animation: dropdownPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.select-dropdown-cidade {
  width: 100%;
}

@keyframes dropdownPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-search-wrap {
  position: relative;
  margin-bottom: 6px;
}

.dropdown-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #86868b;
  pointer-events: none;
}

.dropdown-search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 10px 0 32px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 0.85rem;
  outline: none;
  font-family: var(--font-stack);
  background: #fbfbfd;
}

.dropdown-search-wrap input:focus {
  border-color: var(--wpp-green);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.15);
}

.dropdown-options {
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}

.dropdown-options::-webkit-scrollbar {
  width: 5px;
}

.dropdown-options::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-options::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

.dropdown-option {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease;
  user-select: none;
}

.dropdown-option:hover,
.dropdown-option.is-focused {
  background: #f0fdf4;
  color: var(--wpp-green-dark);
}

.dropdown-option.is-selected {
  background: rgba(37, 211, 102, 0.12);
  font-weight: 700;
  color: var(--wpp-green-dark);
}

.dropdown-option-badge {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.dropdown-empty {
  padding: 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
}

/* ==========================================================================
   CHECKBOX DE CONSENTIMENTO
   ========================================================================== */
.consent-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid transparent;
  transition: var(--transition);
}

.consent-box.has-error {
  border-color: var(--danger-color);
  background: var(--danger-bg);
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.consent-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 6px;
  border: 1.5px solid #c7c7cc;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.check-icon {
  width: 13px;
  height: 13px;
  color: #ffffff;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.consent-label input:checked + .checkbox-custom {
  background: var(--wpp-green);
  border-color: var(--wpp-green);
}

.consent-label input:checked + .checkbox-custom .check-icon {
  opacity: 1;
  transform: scale(1);
}

.consent-text {
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.privacy-link {
  color: var(--text-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.privacy-link:hover {
  color: var(--wpp-green-dark);
}

/* ==========================================================================
   BOTÃO VERDE DE AÇÃO CTA (WHATSAPP GREEN)
   ========================================================================== */
.btn-submit-green {
  width: 100%;
  height: 56px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  background: var(--btn-green-gradient);
  color: #ffffff;
  font-family: var(--font-stack);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px -3px var(--btn-green-glow),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: var(--transition);
  margin-top: 6px;
  user-select: none;
}

.btn-submit-green:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -2px rgba(37, 211, 102, 0.5);
}

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

/* Loader */
.btn-loader {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.spinner-white {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ==========================================================================
   RESPONSIVIDADE MOBILE
   ========================================================================== */
@media (max-width: 480px) {
  body {
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .form-modal-card {
    padding: 32px 18px 26px;
    border-radius: 24px;
  }

  .main-title {
    font-size: 1.45rem;
  }

  .group-uf {
    width: 105px;
  }
  
  .select-dropdown {
    position: absolute;
    min-width: 100%;
  }

  .select-dropdown-cidade {
    min-width: 220px;
  }
}
