/* PR #361 Fase B (2026-06-03): Modal checkout overlay.
   Reutilizável em qualquer página. Mobile-first. WCAG AA. */

.nv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #0f172a;
}
.nv-modal-overlay[hidden] { display: none; }

.nv-modal-content {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.nv-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.nv-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.nv-modal-close {
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
}
.nv-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.nv-modal-close:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

.nv-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

.nv-section {
  margin-bottom: 22px;
}
.nv-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px;
}

.nv-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 6px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.nv-item-row:hover { background: #f1f5f9; }
.nv-item-row.nv-locked {
  opacity: 0.45;
  background: #fff;
  border-color: #e2e8f0;
  cursor: not-allowed;
}
.nv-item-row.nv-locked .nv-item-label { cursor: not-allowed; }
.nv-item-row.nv-locked::after {
  content: '🔒';
  margin-left: 8px;
  font-size: 14px;
}

.nv-locked-base {
  background: #f0f9ff;
  border-color: #bae6fd;
  cursor: default;
}
.nv-locked-base:hover { background: #f0f9ff; }

.nv-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.nv-item-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.nv-item-label input[type="checkbox"]:disabled { cursor: not-allowed; }
.nv-item-name {
  font-size: 14.5px;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nv-item-price {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  margin-left: 12px;
  white-space: nowrap;
}

.nv-bairro-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 0 12px;
}
.nv-bairro-select-row label {
  font-size: 13px;
  color: #64748b;
}
.nv-bairro-select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.nv-items-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.nv-help-text {
  font-size: 12.5px;
  color: #64748b;
  margin: 6px 0 0 32px;
}

.nv-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
}
.nv-banner-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #075985;
}
.nv-banner-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

/* ── Footer + progress ───────────────────────────────────────── */

.nv-modal-footer {
  border-top: 1px solid #e2e8f0;
  padding: 14px 22px 18px;
  flex-shrink: 0;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

.nv-progress-wrapper {
  margin-bottom: 12px;
}
.nv-progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.nv-progress-fill {
  height: 100%;
  background: #16a34a;
  transition: width 0.18s, background 0.18s;
}
.nv-progress-fill.nv-progress-warning { background: #f59e0b; }
.nv-progress-fill.nv-progress-full { background: #dc2626; }

@keyframes nv-pulse-red {
  0%, 100% { background: #dc2626; }
  50% { background: #f87171; }
}

.nv-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.nv-total-info strong {
  font-size: 17px;
  color: #0f172a;
}
.nv-meta {
  font-size: 12.5px;
  color: #64748b;
  margin-left: 8px;
}

.nv-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.nv-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 44px; /* WCAG touch target */
  transition: background 0.12s, border-color 0.12s;
}
.nv-btn-primary {
  background: #2563eb;
  color: #fff;
}
.nv-btn-primary:hover { background: #1d4ed8; }
.nv-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.nv-btn-ghost {
  background: #fff;
  border-color: #cbd5e1;
  color: #0f172a;
}
.nv-btn-ghost:hover { background: #f8fafc; border-color: #94a3b8; }
.nv-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ── Popups (limite + uplift form) ───────────────────────────── */

.nv-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.nv-popup-overlay[hidden] { display: none; }
.nv-popup-content {
  background: #fff;
  border-radius: 14px;
  max-width: 460px;
  width: 100%;
  padding: 22px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.nv-popup-content h3 {
  margin: 0 0 10px;
  font-size: 17px;
}
.nv-popup-content p {
  margin: 0 0 10px;
  font-size: 14px;
  color: #475569;
  line-height: 1.5;
}
.nv-popup-content .nv-help-text {
  margin-left: 0;
  margin-top: 14px;
}

.nv-uplift-form .nv-field {
  margin-bottom: 12px;
}
.nv-uplift-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 4px;
}
.nv-uplift-form .nv-optional {
  color: #94a3b8;
  font-weight: 400;
}
.nv-uplift-form input[type="number"],
.nv-uplift-form input[type="text"],
.nv-uplift-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.nv-uplift-form input:focus,
.nv-uplift-form textarea:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: #2563eb;
}
.nv-uplift-form textarea { resize: vertical; }

.nv-result {
  padding: 12px 14px;
  border-radius: 8px;
  margin: 10px 0 14px;
  font-size: 13.5px;
}
.nv-result-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.nv-result-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

@media (max-width: 600px) {
  .nv-modal-content {
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
  .nv-modal-overlay { padding: 0; }
  .nv-actions { flex-direction: column-reverse; }
  .nv-btn { width: 100%; }
}

/* ── Sub-modal de confirmação + pagamento (checkout wiring) ───────────── */
/* Reusa o padrão visual do .nv-uplift-form para campos/labels/inputs. */
.nv-confirm-form .nv-field { margin-bottom: 12px; }
.nv-confirm-form > label,
.nv-confirm-form .nv-field > label,
.nv-confirm-form legend {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 4px;
}
.nv-confirm-form .nv-optional { color: #94a3b8; font-weight: 400; }
.nv-confirm-form input[type="text"],
.nv-confirm-form input[type="email"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.nv-confirm-form input:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: #2563eb;
}

.nv-confirm-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.nv-confirm-summary ul {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 13.5px;
  color: #334155;
}
.nv-confirm-summary li { margin-bottom: 3px; }
.nv-confirm-total {
  margin: 0 !important;
  font-weight: 700;
  font-size: 15px !important;
  color: #0f172a !important;
}

/* Forma de pagamento (radios) */
.nv-billing { border: none; padding: 0; margin: 0 0 12px; }
.nv-billing label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 400; color: #334155; font-size: 14px;
  padding: 6px 0; cursor: pointer;
}
.nv-billing input[type="radio"] { width: auto; margin: 0; }

/* Checkbox rows (NF + termos) */
.nv-checkbox-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13.5px; color: #334155; line-height: 1.45;
  margin-bottom: 12px; cursor: pointer;
}
.nv-checkbox-row input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.nv-terms-row { font-weight: 500; }
.nv-checkbox-row a { color: #2563eb; }

/* ── Endereço fiscal (NF) — revelado ao marcar "quero nota fiscal" ──────── */
/* Os inputs (type=text) herdam o estilo de .nv-confirm-form input; aqui só o
   layout (grid rua+número / bairro+cidade+UF) e o destaque visual da seção. */
.nv-nf-address {
  border-left: 3px solid #2563eb;
  padding: 2px 0 2px 12px;
  margin: 0 0 14px;
}
.nv-nf-addr-intro {
  margin: 2px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.nv-nf-address .nv-field { margin-bottom: 10px; }
.nv-addr-grid-2 { display: grid; grid-template-columns: 1fr 96px; gap: 10px; }
.nv-addr-grid-3 { display: grid; grid-template-columns: 1fr 1fr 64px; gap: 10px; }
.nv-addr-uf-field input { text-transform: uppercase; }
.nv-nf-address .nv-bairro-caption { font-size: 12px; color: #64748b; margin: 5px 0 0; }
.nv-nf-address .nv-error-caption { color: #dc2626; }
@media (max-width: 460px) {
  .nv-addr-grid-2,
  .nv-addr-grid-3 { grid-template-columns: 1fr; }
}

/* ── Busca de bairro + chips + aviso de distrito duplicado (Fix #424) ───── */
/* Bairro principal vira input de busca (datalist) com legenda do distrito. */
.nv-bairro-select-row { flex-wrap: wrap; }
.nv-bairro-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.nv-bairro-input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
.nv-bairro-caption {
  flex-basis: 100%;
  font-size: 12.5px;
  color: #64748b;
  margin: 4px 0 0;
}
.nv-bairro-caption.nv-error-caption { color: #b91c1c; }

/* Adicionar bairro: input de busca + botão; chips abaixo. */
.nv-add-bairro-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 12px 0;
}
.nv-add-bairro-row .nv-bairro-input { flex: 1 1 auto; min-width: 0; }
/* Botao "Adicionar" compacto: so o tamanho do texto. A especificidade (0,2,0)
   vence o `.nv-btn { width:100% }` do @media <=600px (que e proposital APENAS
   para os botoes de acao do rodape, nao para este botao inline). */
.nv-add-bairro-row .nv-btn-add { flex: 0 0 auto; width: auto; white-space: nowrap; padding: 8px 14px; }
.nv-add-bairro-msg { margin: 6px 12px 0; }

.nv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 12px 0;
}
.nv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  color: #1e3a5f;
}
.nv-chip-label { line-height: 1.2; }
.nv-chip-remove {
  border: none;
  background: #dbeafe;
  color: #1d4ed8;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nv-chip-remove:hover { background: #bfdbfe; }
.nv-chip-remove:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }

/* Objetivo do relatório (foco): morar / investir / incorporar */
.nv-foco-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.nv-foco-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.nv-foco-opt:hover { background: #f8fafc; }
.nv-foco-opt input { margin-top: 3px; accent-color: #0F5499; flex: 0 0 auto; }
.nv-foco-text { display: flex; flex-direction: column; line-height: 1.25; }
.nv-foco-text strong { font-size: 14px; color: #0f172a; }
.nv-foco-text small { font-size: 11.5px; color: #64748b; }
/* PR-C comercial: opção de foco desabilitada no mode comercial ("Morar").
   Continua visível (o usuário entende o porquê via title) mas não-interativa. */
.nv-foco-opt.nv-foco-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f8fafc;
}
.nv-foco-opt.nv-foco-disabled:hover { background: #f8fafc; }
/* destaque da opção selecionada (label que contém o radio marcado) */
.nv-foco-opt:has(input:checked) {
  border-color: #0F5499;
  background: #f0f9ff;
  box-shadow: 0 0 0 1px #0F5499 inset;
}
.nv-foco-opt:has(input:focus-visible) { outline: 2px solid #2563eb; outline-offset: 1px; }
@media (max-width: 520px) {
  .nv-foco-options { grid-template-columns: 1fr; }
}

/* ── Add-on Endereço específico (T6) ─────────────────────────────────────── */
.nv-endereco-tag {
  font-size: 12.5px; font-weight: 600; color: #0F5499;
  background: #f0f9ff; border: 1px solid #bfdbfe; border-radius: 6px;
  padding: 1px 8px; margin-left: 6px; vertical-align: 2px; white-space: nowrap;
}
.nv-endereco-row { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.nv-endereco-bairro {
  flex: 0 0 auto; max-width: 42%; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff;
  color: #0f172a; box-sizing: border-box;
}
.nv-endereco-input {
  flex: 1 1 auto; min-width: 0; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
  color: #0f172a; box-sizing: border-box;
}
.nv-endereco-input:focus, .nv-endereco-bairro:focus {
  outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb;
}
.nv-endereco-dd-wrap { position: relative; }
.nv-endereco-dropdown {
  position: absolute; top: 2px; left: 0; right: 0; z-index: 30; list-style: none;
  margin: 0; padding: 4px; background: #fff; border: 1px solid #cbd5e1;
  border-radius: 8px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
}
.nv-endereco-dropdown[hidden] { display: none; }
.nv-endereco-suggestion {
  padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
  color: #0f172a; line-height: 1.3;
}
.nv-endereco-suggestion:hover { background: #f0f9ff; }
.nv-endereco-suggestion-red { color: #94a3b8; cursor: not-allowed; }  /* 🔴 sem dados → não vendável */
.nv-endereco-suggestion-red:hover { background: transparent; }
@media (max-width: 520px) {
  .nv-endereco-row { flex-wrap: wrap; }
  .nv-endereco-bairro { max-width: 100%; flex: 1 1 100%; }
}

/* ── Indicador "pensando" — feedback visível durante qualquer espera (UX) ──
   Reutilizável: .nv-thinking (status inline) + .nv-btn.is-loading (botão).
   Respeita prefers-reduced-motion (pulsa em vez de girar). Sem layout shift. */
@keyframes nv-spin { to { transform: rotate(360deg); } }
@keyframes nv-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.nv-spinner {
  display: inline-block; width: 13px; height: 13px; flex: 0 0 auto; vertical-align: -2px;
  border: 2px solid rgba(37, 99, 235, .25); border-top-color: #2563eb;
  border-radius: 50%; animation: nv-spin .6s linear infinite;
}
.nv-thinking { display: inline-flex; align-items: center; gap: 7px; color: #475569; font-size: 13px; }
.nv-btn.is-loading { pointer-events: none; }
.nv-btn.is-loading::before {
  content: ''; display: inline-block; width: 13px; height: 13px; margin-right: 8px;
  vertical-align: -2px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  border-radius: 50%; animation: nv-spin .6s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .nv-spinner, .nv-btn.is-loading::before { animation: nv-pulse 1.1s ease-in-out infinite; }
}

/* ── Hidratação do modal (perf 2026-07-23) ────────────────────────────────
   O modal abre no mesmo frame do clique e os dados chegam depois. Enquanto
   não chegam, o preço vira ESQUELETO — nunca o default hardcoded do JS, que
   pisca e muda debaixo do cliente numa tela de pagamento.
   O esqueleto ocupa o mesmo espaço do texto final (color:transparent, largura
   mínima em ch) → zero layout shift ao hidratar. */
@keyframes nv-skeleton { 0%, 100% { opacity: .55; } 50% { opacity: .95; } }

.nv-hydrating-price .nv-price-slot {
  color: transparent !important;
  background: linear-gradient(90deg, #e2e8f0, #eef2f7, #e2e8f0);
  border-radius: 5px;
  min-width: 6.5ch;
  display: inline-block;
  animation: nv-skeleton 1.2s ease-in-out infinite;
  user-select: none;
}
.nv-hydrating-price #nv-total-meta { min-width: 18ch; }

/* Campo de bairro desabilitado durante o carregamento da lista real. */
.nv-hydrating-bairros .nv-bairro-input:disabled,
.nv-hydrating-bairros .nv-btn-add:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: progress;
}

.nv-banner-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .nv-hydrating-price .nv-price-slot { animation: none; }
}
