/**
 * Venda de Plano - BRA Benefícios
 * Mobile-first, responsivo, otimizado para telas pequenas
 */

/* === Cor sólida no header === */
body.bra-venda-plano-page {
  background: linear-gradient(180deg, #124a89 0%, #124a89 100%) top center / 100% 4rem no-repeat, #f0f8ff !important;
  min-height: 100vh;
}

body.bra-venda-plano-page .venda-plano-section {
  background: transparent !important;
}

/* === Variáveis === */
:root {
  --venda-padding-x: 1rem;
  --venda-padding-y: 1rem;
  --venda-gap: 0.75rem;
  --venda-input-height: 2.75rem;
  --venda-btn-height: 2.75rem;
  --venda-safe-top: env(safe-area-inset-top);
  --venda-safe-bottom: env(safe-area-inset-bottom);
}

/* === Faixa indicação (URL /venda-plano/r/:codigo) === */
.venda-ref-banner {
  width: 100%;
  min-height: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #15803d;
  color: #f0fdf4;
  font-size: 0.75rem;
  line-height: 1.2;
  padding: 0 0.75rem;
  box-sizing: border-box;
  overflow: hidden;
}

.venda-ref-banner__inner {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.venda-ref-banner__sep {
  opacity: 0.85;
}

.venda-ref-banner__code {
  font-family: ui-monospace, monospace;
  font-weight: 600;
}

@media (max-width: 480px) {
  .venda-ref-banner__inner {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .venda-ref-banner {
    height: auto;
    min-height: 30px;
    padding: 4px 0.5rem;
  }
}

/* === Barra info vendedor === */
.venda-vendedor-bar {
  position: sticky;
  top: 4rem;
  z-index: 100;
  margin-top: 4rem;
  background: var(--bra-verde, #4CAF50);
  color: white;
  padding: 0.875rem 1.25rem;
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.venda-vendedor-bar__inner {
  max-width: 32rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  font-size: 0.9375rem;
}

.venda-vendedor-bar__item strong {
  font-weight: 600;
  margin-right: 0.25rem;
}

@media (min-width: 1024px) {
  .venda-vendedor-bar__inner {
    max-width: 36rem;
  }
}

.venda-vendedor-bar--modo-direta {
  display: none !important;
}

.venda-vendedor-bar--modo-vendedor {
  display: block !important;
}

/* Barra em estado de erro (CPF vendedor inválido) */
.venda-vendedor-bar--erro {
  background: #dc2626 !important;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

.venda-vendedor-bar--erro .venda-vendedor-bar__item {
  display: none;
}

.venda-vendedor-bar__erro {
  font-weight: 600;
}

.venda-vendedor-bar__erro.hidden {
  display: none !important;
}

.venda-vendedor-bar--erro .venda-vendedor-bar__erro {
  display: block !important;
}

/* === Layout principal - Mobile first === */
.venda-plano-section {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(5rem + var(--venda-safe-top)) 0 calc(1.5rem + var(--venda-safe-bottom));
}

.venda-plano-section .bra-section__inner.venda-plano-container {
  max-width: 32rem;
  padding-left: max(var(--venda-padding-x), env(safe-area-inset-left));
  padding-right: max(var(--venda-padding-x), env(safe-area-inset-right));
}

.venda-plano-container {
  max-width: 28rem;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .venda-plano-container {
    max-width: 36rem;
  }
  .venda-plano-section {
    padding-top: calc(6rem + var(--venda-safe-top));
    padding-bottom: 2rem;
  }
}

@media (min-width: 768px) {
  .venda-plano-container {
    max-width: 42rem;
  }
}

@media (min-width: 1024px) {
  .venda-plano-section .bra-section__inner.venda-plano-container {
    max-width: 36rem;
  }
}

/* === Header compacto === */
.venda-plano-header .bra-section-eyebrow {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.venda-plano-header {
  margin-bottom: 1rem;
}

.venda-plano-title {
  font-size: 1.25rem;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.venda-plano-subtitle {
  font-size: 0.8125rem;
  line-height: 1.4;
  margin-bottom: 0;
}

@media (min-width: 640px) {
  .venda-plano-header {
    margin-bottom: 1.25rem;
  }
  .venda-plano-title {
    font-size: 1.5rem;
  }
  .venda-plano-subtitle {
    font-size: 0.9375rem;
  }
}

/* === Steps indicator - compacto em mobile === */
.venda-plano-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
}

/* Cinco etapas: permite quebra em telas estreitas */
.venda-plano-steps--5 {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}

.venda-step {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.venda-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: #e2e8f0;
  font-weight: 700;
  font-size: 0.6875rem;
}

.venda-step-connector {
  width: 0.375rem;
  height: 2px;
  background: #e2e8f0;
  flex-shrink: 0;
}

.venda-step-label {
  display: none;
}

@media (min-width: 480px) {
  .venda-step {
    padding: 0.4rem 0.6rem;
    font-size: 0.8125rem;
  }
  .venda-step-label {
    display: inline;
  }
  .venda-step-connector {
    width: 0.5rem;
  }
}

@media (min-width: 640px) {
  .venda-plano-steps {
    gap: 0.25rem;
    margin-bottom: 1.5rem;
  }
  .venda-step {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  .venda-step-num {
    min-width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
  }
  .venda-step-connector {
    width: 1rem;
  }
}

.venda-step.active {
  background: var(--bra-azul-claro, #E3F2FD);
  color: var(--bra-base-escuro, #19395E);
}

.venda-step.active .venda-step-num {
  background: var(--bra-base-escuro, #19395E);
  color: white;
}

.venda-step.done {
  background: var(--bra-teal-claro, #E8F5E9);
  color: var(--bra-verde-escuro, #388E3C);
}

/* === Etapa cupom === */
.venda-card-cupom .venda-cupom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}

.venda-card-cupom .venda-cupom-input {
  flex: 1 1 12rem;
  min-width: 0;
}

.venda-btn-cupom {
  flex-shrink: 0;
  white-space: nowrap;
}

.venda-step.done .venda-step-num {
  background: var(--bra-verde, #4CAF50);
  color: white;
}

/* === Cards === */
.venda-plano-card {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.venda-plano-card:last-child {
  margin-bottom: 0;
}

@media (min-width: 640px) {
  .venda-plano-card {
    padding: 1.5rem;
    border-radius: 1rem;
  }
}

/* === Títulos e descrições === */
.venda-etapa-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--bra-base-escuro, #19395E);
  margin-bottom: 0.25rem;
}

.venda-etapa-desc {
  color: #6b7280;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.venda-secao-titulo {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.venda-secao-desc {
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}

.venda-subtitle {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--bra-base-escuro, #19395E);
  margin-bottom: 0.5rem;
}

/* === Formulários - touch-friendly === */
.venda-form-group {
  margin-bottom: 0.75rem;
}

.venda-form-group:last-child {
  margin-bottom: 0;
}

.venda-form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.venda-form-input {
  width: 100%;
  height: var(--venda-input-height);
  min-height: 44px;
  padding: 0 0.875rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.venda-form-input:focus {
  outline: none;
  border-color: var(--bra-verde, #4CAF50);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.venda-form-input.border-red-500 {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.2);
}

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

.venda-input-readonly {
  background: #f9fafb;
  color: #6b7280;
}

.venda-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}

.venda-form-grid > .venda-form-group {
  flex: 1 1 100%;
}

.venda-form-grid-compact .venda-form-group {
  flex: 1 1 calc(50% - 0.5rem);
  min-width: 0;
}

.venda-form-group-cep {
  flex: 1 1 40% !important;
  min-width: 6rem;
}

.venda-form-group-uf {
  flex: 0 0 4rem !important;
}

.venda-form-group-full {
  flex: 1 1 100% !important;
}

@media (min-width: 640px) {
  .venda-form-grid > .venda-form-group {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }
  .venda-form-group-cep {
    flex: 1 1 30% !important;
  }
}

/* Beneficiários */
.venda-secao {
  margin-bottom: 1.25rem;
}

.beneficiario-item {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
}

.beneficiario-item:last-child {
  margin-bottom: 0;
}

.beneficiario-titulo {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

/* === Botões === */
.venda-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-direction: column;
}

@media (min-width: 480px) {
  .venda-buttons {
    flex-direction: row;
  }
}

.venda-btn-primary {
  flex: 1;
  min-height: var(--venda-btn-height);
  padding: 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--bra-base-escuro, #19395E), #2d4a6f);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.venda-btn-primary:hover {
  background: linear-gradient(135deg, #0f2744, var(--bra-base-escuro, #19395E));
}

.venda-btn-primary:active {
  transform: scale(0.98);
}

.venda-btn-secondary {
  flex: 1;
  min-height: var(--venda-btn-height);
  padding: 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bra-base-escuro, #19395E);
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.venda-btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* === Planos (exibição simples) === */
.venda-card-planos {
  margin-bottom: 1rem;
}

.venda-planos-simples {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 360px) {
  .venda-planos-simples {
    flex-direction: row;
    gap: 0.75rem;
  }
}

.venda-plano-opcao {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 4.5rem;
  padding: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.venda-plano-opcao:active {
  transform: scale(0.98);
}

.venda-plano-opcao__nome {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #374151;
}

.venda-plano-opcao__preco {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bra-base-escuro, #19395E);
}

.venda-plano-opcao__preco small {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
}

.venda-plano-opcao__badge {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--bra-verde, #4CAF50);
}

.venda-plano-opcao--popular {
  border-color: #e5e7eb;
  background: #fafafa;
}

.venda-plano-item {
  cursor: pointer;
}

.venda-plano-item.venda-plano-selecionado {
  border-color: var(--bra-verde, #4CAF50);
  background: #E8F5E9;
  box-shadow: 0 0 0 1px var(--bra-verde, #4CAF50);
}

.venda-plano-item.venda-plano-selecionado .venda-plano-opcao__preco {
  color: var(--bra-verde-escuro, #388E3C);
}

/* === Pagamento === */
.venda-resumo-plano {
  padding: 1rem;
  background: #f9fafb;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.venda-resumo-nome {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.25rem;
}

.venda-resumo-valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--bra-base-escuro, #19395E);
  margin: 0;
}

.venda-pagamento-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.venda-tab {
  flex: 1;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.venda-tab.active {
  background: var(--bra-base-escuro, #19395E);
  color: white;
}

.venda-pix-mock {
  padding: 1.5rem;
  border: 2px dashed var(--bra-verde, #4CAF50);
  border-radius: 0.75rem;
  background: #E8F5E9;
  text-align: center;
}

.venda-pix-qr {
  width: 5rem;
  height: 5rem;
  margin: 0 auto 0.75rem;
  background: white;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.venda-pix-icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--bra-verde, #4CAF50);
}

.venda-pix-texto {
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.venda-pix-hint {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0;
}

.venda-cartao-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.75rem;
}

/* === Sucesso === */
.venda-card-sucesso {
  text-align: center;
  padding: 2rem 1.5rem;
}

.venda-sucesso-icone {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #E8F5E9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.venda-sucesso-check {
  width: 2rem;
  height: 2rem;
  color: var(--bra-verde, #4CAF50);
}

.venda-sucesso-titulo {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.venda-sucesso-desc {
  font-size: 0.9375rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

.venda-card-sucesso .venda-btn-primary {
  max-width: 14rem;
  margin: 0 auto;
}

/* === Loader CPF (transição vendedor → cliente) === */
.venda-cpf-card__form.hidden {
  display: none !important;
}

.venda-cpf-card__loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
}

.venda-cpf-card__loader.hidden {
  display: none !important;
}

.venda-loader-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(18, 74, 137, 0.2);
  border-top-color: var(--bra-base-escuro, #19395E);
  border-radius: 50%;
  animation: vendaLoaderSpin 0.8s linear infinite;
}

.venda-loader-text {
  font-size: 0.875rem;
  color: #64748b;
}

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

/* === Erro === */
.venda-erro {
  font-size: 0.8125rem;
  color: #dc2626;
  margin-top: 0.25rem;
}

.venda-erro.hidden {
  display: none;
}

/* === Animação === */
.venda-etapa {
  animation: vendaFadeIn 0.25s ease;
}

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

/* === Esconder footer em mobile na venda-plano para ganhar espaço === */
.venda-plano-mobile .bra-footer {
  padding-top: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.venda-plano-mobile .bra-footer__inner {
  padding: 0 1rem;
}

/* Checkbox "Informar familiar depois" (Plano Familiar) */
.venda-chk-familiar-wrap {
  margin-bottom: 1rem;
}

.venda-checkbox-familiar {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.4;
}

.venda-checkbox-familiar input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  accent-color: #0c4a6e;
}

#listaBeneficiariosWrapper.hidden {
  display: none;
}
