/* ============================================
   NODO — Polimento Final
   Microinterações, mobile, acessibilidade
   ============================================ */

/* ========== MICROINTERAÇÕES ========== */

/* Transição entre telas do form */
.form-step {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.form-step.active {
  opacity: 1;
  transform: translateY(0);
}

/* Input focus com glow sutil */
.input-field:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(1, 31, 255, 0.1);
}

/* Botão com ripple ao clicar */
.btn-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.btn-primary:active::after {
  opacity: 1;
}

/* Chip com bounce ao selecionar */
.chip {
  transition: all var(--transition-fast), transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chip.selected {
  transform: scale(1.02);
}

.chip:active {
  transform: scale(0.95);
}

/* Upload area — feedback visual aprimorado */
.upload-area {
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(1, 31, 255, 0.05), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.upload-area:hover::before {
  opacity: 1;
}

.upload-area.has-file {
  background-color: rgba(0, 214, 126, 0.05);
}

.upload-area.has-file .upload-area__icon {
  animation: bounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounceIn {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Progress bar com brilho animado */
.progress-bar__fill {
  position: relative;
  overflow: hidden;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s ease infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Radio selecionado com feedback */
.radio-option {
  transition: all var(--transition-fast), transform 0.15s ease;
}

.radio-option:active {
  transform: scale(0.98);
}

.radio-option.selected {
  border-color: var(--color-blue);
  background: rgba(1, 31, 255, 0.04);
}

/* Calc card com entrada animada */
.calc-card {
  animation: slideUp 0.3s ease;
}

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

/* Loading no botão submit */
.btn-primary:disabled {
  position: relative;
}

.btn-primary:disabled::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  display: inline-block;
  vertical-align: middle;
}

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

/* Toast de erro com saída */
.toast-error {
  animation: toastIn 0.3s ease, toastOut 0.3s ease 4.7s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ========== MOBILE OTIMIZADO ========== */

/* Touch targets mínimos de 44px */
.radio-option,
.chip,
.checkbox-group,
.checkbox-inline,
.upload-area {
  min-height: 44px;
}

/* Evita zoom no iOS (inputs < 16px causam zoom) */
.input-field,
select.input-field,
textarea.input-field {
  font-size: 16px; /* NUNCA menos que 16px em mobile */
}

/* Safe area pra notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .page {
    padding-top: calc(var(--space-5) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }

  .progress-bar {
    top: env(safe-area-inset-top);
  }
}

/* Scroll suave e momentum no iOS */
.page--form {
  -webkit-overflow-scrolling: touch;
}

/* Campo ativo não fica escondido pelo teclado virtual */
.input-field:focus {
  scroll-margin-bottom: 120px;
}

/* Mobile: botões full-width com espaço extra no bottom */
@media (max-width: 480px) {
  .form-step__nav {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--color-black) 80%, transparent);
    padding: var(--space-3) 0 var(--space-2);
    margin-top: var(--space-4);
    z-index: 10;
  }

  .btn {
    padding: 16px 24px;
    font-size: var(--text-base);
  }

  /* Chips menores em tela pequena */
  .chip {
    padding: 8px 12px;
    font-size: var(--text-xs);
  }

  /* Upload grid sempre 1 coluna em mobile estreito */
  .uploads-grid {
    grid-template-columns: 1fr;
  }
}

/* Landscape mobile — reduz padding vertical */
@media (max-height: 500px) and (orientation: landscape) {
  .page {
    padding: var(--space-2) 0;
  }

  .form-step__title {
    font-size: var(--text-xl);
    margin-bottom: var(--space-2);
  }
}

/* ========== ACESSIBILIDADE ========== */

/* Focus visible (navegação por teclado) */
*:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

/* Remove outline no mouse, mantém no teclado */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link (escondido até tab) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-2);
  padding: 8px 16px;
  background: var(--color-blue);
  color: var(--color-white);
  border-radius: var(--radius-md);
  z-index: 1000;
  font-size: var(--text-sm);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: var(--space-1);
}

/* Contraste reforçado nos placeholders */
.input-field::placeholder {
  color: var(--color-gray-light);
  opacity: 0.7; /* Garante contraste mínimo 4.5:1 com fundo */
}

/* Mensagens de erro acessíveis */
.input-error {
  role: alert;
}

/* Redução de motion pra quem prefere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .progress-bar__fill::after {
    display: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .input-field {
    border-width: 2px;
  }

  .chip {
    border-width: 2px;
  }

  .radio-option {
    border-width: 2px;
  }
}

/* ========== ESTADOS VISUAIS REFINADOS ========== */

/* Select com seta customizada */
select.input-field {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23A8A8A8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

/* Textarea com resize indicator */
textarea.input-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M9 1L1 9M9 5L5 9M9 9L9 9' stroke='%233A3A3A' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: bottom 8px right 8px;
}

/* Checkbox e radio com transição suave */
.radio-option input[type="radio"],
.checkbox-group input[type="checkbox"],
.checkbox-inline input[type="checkbox"] {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.radio-option input[type="radio"]:checked,
.checkbox-group input[type="checkbox"]:checked,
.checkbox-inline input[type="checkbox"]:checked {
  transform: scale(1.1);
}

/* Link da tela de sucesso com hover */
.success-screen .btn-secondary:hover {
  background: rgba(1, 31, 255, 0.1);
  border-color: var(--color-blue);
  color: var(--color-blue);
}
