/* ==========================================================================
   DESIGN SYSTEM & VARIABLES — Conecta Media Forms
   ========================================================================== */

:root {
  --primary-accent: #F47A25;
  --primary-accent-glow: rgba(244, 122, 37, 0.3);
  --primary-accent-hover: #d66015;
  --bg-gradient: linear-gradient(135deg, #121214 0%, #0a0a0b 100%);
  --card-bg: rgba(12, 12, 16, 0.18);
  --card-border: rgba(255, 255, 255, 0.08);
  
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-label: #E5E7EB;
  
  --input-bg: rgba(10, 10, 12, 0.5);
  --input-border: rgba(255, 255, 255, 0.12);
  --input-border-focus: rgba(244, 122, 37, 0.6);
  
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  
  --font-sans: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Lemon Milk', var(--font-sans);
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: #08080a;
  background-image: url('assets/BG_formulario3.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Dark overlay above the background image to ensure contrast */
.background-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(10, 10, 15, 0.4) 0%, rgba(5, 5, 8, 0.88) 100%);
  z-index: 1;
  pointer-events: none;
}

/* ==========================================================================
   LAYOUT CONTAINER
   ========================================================================== */

.main-container {
  flex: 1;
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ==========================================================================
   HEADER SECTION & ANIMATIONS
   ========================================================================== */

.header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}

/* Logo Animado */
.logo-container {
  opacity: 0;
  transform: translateY(-20px);
  animation: fadeInDown 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.app-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(244, 122, 37, 0.3));
}

/* Timeline Animada */
.timeline-container {
  width: 100%;
  max-width: 580px;
  opacity: 0;
  transform: scale(0.92) translateY(10px);
  animation: fadeInUp 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

.timeline-image {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Títulos Animados */
.title-container {
  opacity: 0;
  transform: translateY(15px);
  animation: fadeInUp 0.8s ease-out 0.4s forwards;
  max-width: 680px;
}

.main-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.accent-text {
  color: var(--primary-accent);
  position: relative;
  display: inline-block;
}

.subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* ==========================================================================
   GLASSMORPHISM CARD
   ========================================================================== */

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 40px;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s ease-out 0.6s forwards;
}

/* ==========================================================================
   COMMON STATE CONTAINER (Loading, Error, Success)
   ========================================================================== */

.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 10px;
  min-height: 250px;
}

.hidden {
  display: none !important;
}

/* Spinner Loader */
.spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(255, 255, 255, 0.07);
  border-top: 3.5px solid var(--primary-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
  box-shadow: 0 0 15px rgba(244, 122, 37, 0.15);
}

.state-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Error State */
.error-icon {
  width: 60px;
  height: 60px;
  color: var(--error);
  margin-bottom: 20px;
}

.error-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.error-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.6;
}

/* Success State */
.success-icon {
  width: 72px;
  height: 72px;
  color: var(--success);
  margin-bottom: 24px;
  animation: scaleUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.success-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--success);
  margin-bottom: 14px;
}

.success-desc {
  font-size: 1rem;
  color: var(--text-main);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.success-subdesc {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.5;
}

/* ==========================================================================
   FORM & SECTIONS
   ========================================================================== */

.lead-form {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 32px;
}

.form-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-accent);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 8px;
}

/* ==========================================================================
   TOGGLE CARD DE RELAÇÃO CONTRATUAL
   ========================================================================== */

.relation-selector-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.relation-selector-label {
  font-size: 0.82rem; /* Alinhado com o tamanho dos labels dos inputs normais */
  font-weight: 600;
  color: var(--text-muted); /* Mudado para cinza mais discreto */
  opacity: 0.8; /* Opacidade reduzida */
  letter-spacing: 0.02em; /* Mesma consistência dos outros labels */
  user-select: none;
  text-align: right;
  width: 100%;
  box-sizing: border-box;
  padding-right: 6px; /* Ajuste visual óptico para alinhar com a tangente da curva do botão */
}

.relation-toggle-container {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 30px;
  padding: 2px;
  max-width: 240px; /* Ajustado para caber o texto completo de Pessoa Física/Jurídica de forma limpa */
  margin: 0;
}

.relation-card {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.relation-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.relation-card-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 26px;
  transition: var(--transition-fast);
  text-align: center;
  color: var(--text-muted);
  white-space: nowrap; /* Impede quebra de linha no conteúdo do botão */
}

.relation-title-text {
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0;
  white-space: nowrap; /* Impede quebra de linha no título do botão */
}

.relation-desc-text {
  display: none;
}

/* Hover & Focus relation card */
.relation-card:hover .relation-card-content {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

/* Checked State */
.relation-card input[type="radio"]:checked + .relation-card-content {
  background: rgba(244, 122, 37, 0.12);
  color: var(--primary-accent);
  border: 1px solid var(--primary-accent);
  box-shadow: none;
}

/* ==========================================================================
   FORM INPUTS & LABELS
   ========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.span-2 {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-label);
  letter-spacing: 0.02em;
}

/* Inputs, Selects & Textarea */
input[type="text"],
input[type="email"],
input[type="tel"],
select,
textarea {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: var(--transition-fast);
}

textarea {
  height: auto;
  padding: 16px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  cursor: pointer;
}

/* Placeholder styles */
input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

/* Focus state */
input:focus,
select:focus,
textarea:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 8px var(--primary-accent-glow);
  background: rgba(10, 10, 12, 0.7);
}

/* Addon Input styling (Instagram) */
.input-addon-wrapper {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  transition: var(--transition-fast);
}

.input-addon-wrapper:focus-within {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 8px var(--primary-accent-glow);
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.04);
  border-right: 1px solid var(--input-border);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  user-select: none;
}

.input-addon-wrapper input {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Phone input with DDI and Flag */
.phone-input-wrapper {
  display: flex;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  transition: var(--transition-fast);
}

.phone-input-wrapper:focus-within {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 8px var(--primary-accent-glow);
}

.phone-ddi-addon {
  position: relative;
  cursor: pointer;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  border-right: 1px solid var(--input-border);
  user-select: none;
  padding: 0;
  border-radius: 7px 0 0 7px;
}

.ddi-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  color: var(--text-main);
  font-size: 0.90rem;
  font-weight: 500;
}

.ddi-current .ddi-flag {
  font-size: 1rem;
}

.ddi-current .ddi-code {
  color: var(--text-muted);
}

.ddi-arrow {
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.phone-ddi-addon:focus-within .ddi-arrow,
.phone-ddi-addon:hover .ddi-arrow {
  color: var(--text-main);
}

.ddi-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 100;
  background: #121216;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  list-style: none;
  padding: 6px 0;
  margin: 0;
  min-width: 190px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ddi-dropdown.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ddi-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ddi-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.option-flag {
  font-size: 1.05rem;
}

.option-country {
  flex: 1;
  font-weight: 500;
  text-align: left;
}

.option-code {
  color: var(--primary-accent);
  font-weight: 600;
  font-size: 0.8rem;
}

/* Estilo para DDI Editável (Opção Outro) */
.ddi-code[contenteditable="true"] {
  outline: none;
  border-bottom: 1px dashed var(--primary-accent);
  padding: 0 4px;
  min-width: 16px;
  cursor: text;
  display: inline-block;
  transition: var(--transition-fast);
}

.ddi-code[contenteditable="true"]:focus {
  border-bottom: 1px solid var(--primary-accent);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.phone-input-wrapper input {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Input loaders & wraps */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  padding-right: 48px;
}

.input-loader {
  position: absolute;
  right: 16px;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top: 2px solid var(--primary-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.input-loader.active {
  display: block;
}

.input-helper {
  font-size: 0.75rem;
  color: var(--primary-accent);
  margin-top: 2px;
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.input-helper.active {
  display: block;
}

.field-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

/* ==========================================================================
   VALIDATION ERRORS
   ========================================================================== */

.form-group.invalid input,
.form-group.invalid select,
.form-group.invalid textarea,
.form-group.invalid .input-addon-wrapper,
.form-group.invalid .phone-input-wrapper {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.03);
}

.form-group.invalid input:focus,
.form-group.invalid select:focus,
.form-group.invalid textarea:focus,
.form-group.invalid .phone-input-wrapper:focus-within {
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.error-message {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
  animation: slideDownError 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group.invalid .error-message {
  display: block;
}


/* ==========================================================================
   SUBMIT BUTTON
   ========================================================================== */

.submit-container {
  margin-top: 12px;
}

.submit-btn {
  width: 100%;
  height: 54px;
  background: linear-gradient(135deg, #F47A25 0%, #f99f1b 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(244, 122, 37, 0.3);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

.submit-btn:hover::before {
  left: 100%;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(244, 122, 37, 0.45);
  background: linear-gradient(135deg, #f99f1b 0%, #F47A25 100%);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  text-align: center;
  padding: 32px 20px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.78rem;
  margin-top: auto;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(25px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideDownError {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   RESPONSIVE LAYOUT (MEDIA QUERIES)
   ========================================================================== */

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  
  .main-container {
    padding: 20px 12px;
    gap: 24px;
  }
  
  .form-card {
    padding: 24px 16px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .span-2 {
    grid-column: span 1;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .relation-selector-wrapper {
    align-items: flex-start;
    width: 100%;
    gap: 4px;
  }

  .relation-toggle-container {
    max-width: 100%;
    width: 100%;
  }
  
  .main-title {
    font-size: 1.15rem;
    padding: 0 10px;
  }
  
  .timeline-container {
    padding: 0 8px;
  }
}
