/**
 * ATYS Form Embed Styles
 * Version: 2.1
 * 
 * Estilos base para formulários embebidos
 * Inclui reset CSS para isolamento de estilos externos
 */

/* ============================================
   CSS RESET - Isola o formulário de estilos externos
   ============================================ */

/* Reset container - reverte estilos herdados */
.atys-form-container {
  all: revert;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  color: #1f2937 !important;
  text-align: left !important;
  max-width: 100%;
  box-sizing: border-box !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Reset de todos os elementos dentro do container */
.atys-form-container *,
.atys-form-container *::before,
.atys-form-container *::after {
  box-sizing: border-box !important;
  margin: 0;
  padding: 0;
}

/* Reset de elementos de formulário */
.atys-form-container input,
.atys-form-container select,
.atys-form-container textarea,
.atys-form-container button {
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  color: inherit !important;
  border: none;
  background: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Restaurar appearance para selects */
.atys-form-container select {
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  appearance: menulist;
  cursor: pointer;
}

/* Reset de labels */
.atys-form-container label {
  display: block;
  font-weight: inherit;
  margin: 0;
  padding: 0;
}

/* ============================================
   ESTILOS DO FORMULÁRIO
   ============================================ */

/* Título e Descrição */
.atys-form-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.atys-form-description {
  margin: 0 0 1.5rem 0;
  color: #6b7280;
  font-size: 1rem;
}

/* Formulário com Flexbox para widths personalizados */
.atys-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  width: 100%;
  margin: 0 -0.5rem;
  align-items: flex-start;
}

/* Campos */
.atys-form-field {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex-shrink: 0;
  /* Padding-bottom é aplicado via JavaScript inline baseado no fieldSpacing configurado */
}

.atys-form-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.atys-form-field input,
.atys-form-field select,
.atys-form-field textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.atys-form-field input:focus,
.atys-form-field select:focus,
.atys-form-field textarea:focus {
  outline: none;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

/* Checkbox */
.atys-form-field input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  cursor: pointer;
}

/* Telefone com DDI */
.atys-tel-container {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.atys-tel-container select {
  width: 110px;
  min-width: 110px;
  flex-shrink: 0;
  cursor: pointer;
}

.atys-tel-container input {
  flex: 1;
  min-width: 0;
}

/* File Upload */
.atys-form-field input[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}

.atys-form-field input[type="file"]::file-selector-button {
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  border: none;
  background-color: #f3f4f6;
  color: #374151;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.atys-form-field input[type="file"]::file-selector-button:hover {
  background-color: #e5e7eb;
}

/* Rating */
.atys-rating {
  display: flex;
  gap: 0.25rem;
  font-size: 2rem;
}

.atys-rating-star {
  cursor: pointer;
  color: #fbbf24;
  transition: transform 0.2s;
  user-select: none;
}

.atys-rating-star:hover {
  transform: scale(1.2);
}

/* Slider */
.atys-form-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  outline: none;
  padding: 0;
}

.atys-form-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.atys-form-field input[type="range"]::-webkit-slider-thumb:hover {
  background: #2563eb;
}

.atys-form-field input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.atys-form-field input[type="range"]::-moz-range-thumb:hover {
  background: #2563eb;
}

.slider-value {
  text-align: center;
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 1.25rem;
  color: #1976d2;
}

/* Consentimento LGPD */
.atys-form-consent {
  margin-top: 1rem;
  padding: 1rem;
  background: #f3f4f6;
  border-radius: 6px;
}

.atys-form-consent label {
  display: flex;
  align-items: start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  margin: 0;
}

.atys-form-consent input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  cursor: pointer;
}

/* CAPTCHA */
.atys-form-captcha {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}

/* Botão Submit */
.atys-form-submit {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  text-transform: none !important; /* Força manter maiúsculas/minúsculas originais */
}

.atys-form-submit:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.atys-form-submit:active:not(:disabled) {
  transform: translateY(0);
}

.atys-form-submit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Feedback */
.atys-form-feedback {
  padding: 1rem;
  border-radius: 6px;
  margin-top: 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.atys-form-feedback.success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.atys-form-feedback.error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

/* Error Message */
.atys-form-error {
  padding: 1rem;
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
  border-radius: 6px;
  text-align: center;
}

/* Help Text */
.atys-form-field .help-text {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6b7280;
}

/* Asterisco obrigatório */
.atys-form-field label .required {
  color: #ef4444;
}

/* Responsivo */
@media (max-width: 768px) {
  /* Em mobile, todos os campos ocupam 100% */
  .atys-form-field {
    width: 100% !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    /* padding-bottom é mantido do inline style configurado */
  }

  .atys-form-title {
    font-size: 1.5rem;
  }

  .atys-rating {
    font-size: 1.75rem;
  }

  .atys-form-submit {
    padding: 0.875rem 1rem;
  }
}

@media (max-width: 480px) {
  .atys-form-container {
    padding: 1.5rem;
  }

  .atys-form-title {
    font-size: 1.25rem;
  }

  .atys-rating {
    font-size: 1.5rem;
    gap: 0.15rem;
  }
}

/* Animações */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.atys-form-container {
  animation: fadeIn 0.3s ease-out;
}

/* Loading state */
.atys-form-submit.loading {
  position: relative;
}

.atys-form-submit.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

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

/* Acessibilidade */
.atys-form-field input:focus-visible,
.atys-form-field select:focus-visible,
.atys-form-field textarea:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .atys-form-submit,
  .atys-form-captcha {
    display: none;
  }
}

