/* =============================================================
   COMPONENTES — VM VENDAS E COMPRAS
   ============================================================= */

/* =============================================================
   BOTÕES — REDESENHADOS
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--botao-altura);
  padding: 0 var(--botao-pad-x);
  border-radius: var(--raio-botao);
  font-family: inherit;
  font-size: var(--botao-fonte);
  font-weight: var(--peso-semibold);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease,
              color .15s ease,
              border-color .15s ease,
              transform .1s ease,
              box-shadow .15s ease,
              filter .15s ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--anel-foco);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled,
.btn.esta-desabilitado {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* =============================================================
   VARIAÇÕES DE COR — CONSISTENTES
   ============================================================= */

/* Principal (azul) */
.btn--principal {
  background: var(--cor-principal);
  color: #fff;
}
.btn--principal:hover {
  background: var(--cor-principal-escura);
  color: #fff;
  text-decoration: none;
}

/* Secundário (escuro) */
.btn--secundario {
  background: var(--cor-secundaria);
  color: #fff;
}
.btn--secundario:hover {
  filter: brightness(1.3);
  color: #fff;
  text-decoration: none;
}

/* Destaque (laranja) */
.btn--destaque {
  background: var(--cor-destaque);
  color: #fff;
}
.btn--destaque:hover {
  background: var(--cor-destaque-escura);
  color: #fff;
  text-decoration: none;
}

/* Sucesso (verde) */
.btn--sucesso {
  background: var(--cor-sucesso);
  color: #fff;
}
.btn--sucesso:hover {
  background: var(--cor-sucesso-escura);
  color: #fff;
  text-decoration: none;
}

/* Erro (vermelho) */
.btn--erro {
  background: var(--cor-erro);
  color: #fff;
}
.btn--erro:hover {
  background: var(--cor-erro-escura);
  color: #fff;
  text-decoration: none;
}

/* Contorno (fundo branco, borda azul) */
.btn--contorno {
  background: #fff;
  color: var(--cor-principal);
  border-color: var(--cor-principal);
}
.btn--contorno:hover {
  background: var(--cor-principal);
  color: #fff;
  text-decoration: none;
}

/* Fantasma (só texto) */
.btn--fantasma {
  background: transparent;
  color: var(--cor-principal);
  border-color: transparent;
}
.btn--fantasma:hover {
  background: rgba(14, 165, 233, 0.1);
  color: var(--cor-principal-escura);
  text-decoration: none;
}

/* =============================================================
   TAMANHOS
   ============================================================= */
.btn--sm {
  min-height: var(--botao-altura-sm);
  padding: 0 var(--botao-pad-x-sm);
  font-size: var(--botao-fonte-sm);
}

.btn--lg {
  min-height: var(--botao-altura-lg);
  padding: 0 var(--botao-pad-x-lg);
  font-size: var(--botao-fonte-lg);
}

.btn--bloco { width: 100%; }

.btn--icone {
  padding: 0;
  width: var(--botao-altura);
  min-width: var(--botao-altura);
}

/* =============================================================
   MOBILE — botões maiores para toque (Apple/Google recomendam 48px)
   ============================================================= */
@media (max-width: 640px) {
  .btn {
    min-height: 48px;
    padding: 0 16px;
    font-size: 15px;
  }

  .btn--sm {
    min-height: 40px;
    font-size: 14px;
  }

  .btn--lg {
    min-height: 54px;
    font-size: 16px;
  }

  .btn--icone {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}

/* =============================================================
   BADGES
   ============================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--raio-full);
  font-size: 12px;
  font-weight: var(--peso-semibold);
  line-height: 1.4;
  white-space: nowrap;
}
.badge--neutro    { background: #f1f5f9; color: var(--cor-texto-suave); }
.badge--sucesso   { background: #dcfce7; color: #166534; }
.badge--alerta    { background: #fef3c7; color: #92400e; }
.badge--erro      { background: #fee2e2; color: #991b1b; }
.badge--info      { background: #dbeafe; color: #1e40af; }
.badge--principal { background: var(--cor-principal); color: #fff; }
.badge--destaque  { background: var(--cor-destaque); color: #fff; }

/* =============================================================
   ALERTAS
   ============================================================= */
.alerta {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: var(--raio-md);
  border-left: 4px solid var(--cor-info);
  background: #eff6ff;
  color: #1e3a8a;
  font-size: var(--texto-sm);
  margin-bottom: 16px;
}
.alerta--sucesso { border-color: var(--cor-sucesso); background: #f0fdf4; color: #14532d; }
.alerta--alerta  { border-color: var(--cor-alerta); background: #fffbeb; color: #78350f; }
.alerta--erro    { border-color: var(--cor-erro); background: #fef2f2; color: #7f1d1d; }

/* =============================================================
   FORMULÁRIOS
   ============================================================= */
.campo { margin-bottom: 16px; }
.campo__erro { display: block; color: var(--cor-erro); font-size: 12px; margin-top: 4px; }
.campo__dica { display: block; color: var(--cor-texto-suave); font-size: 12px; margin-top: 4px; }

.campo-grupo { display: flex; gap: 8px; align-items: stretch; }
.campo-grupo > input { flex: 1; }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.checkbox input, .radio input {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--cor-principal);
}

/* =============================================================
   MODAL
   ============================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s;
}

.modal {
  background: #fff;
  border-radius: var(--raio-xl);
  box-shadow: var(--sombra-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: subir .2s;
}

.modal__cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--cor-borda);
}

.modal__titulo { font-size: var(--texto-lg); }
.modal__corpo { padding: 24px; }
.modal__rodape {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--cor-borda);
  background: var(--cor-fundo-suave);
  border-radius: 0 0 var(--raio-xl) var(--raio-xl);
}

.modal__fechar {
  padding: 8px;
  color: var(--cor-texto-suave);
  border-radius: var(--raio-md);
  font-size: 20px;
  line-height: 1;
}
.modal__fechar:hover { background: var(--cor-fundo-suave); color: var(--cor-texto); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   TOASTS
   ============================================================= */
.toast-area-cart {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100% - 40px);
}

/* =============================================================
   AVATAR
   ============================================================= */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--raio-full);
  background: var(--cor-fundo-suave);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--peso-semibold);
  color: var(--cor-texto-suave);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }

/* =============================================================
   ESTADOS VAZIOS
   ============================================================= */
.estado-vazio {
  text-align: center;
  padding: 48px 16px;
  color: var(--cor-texto-suave);
}
.estado-vazio__icone {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--cor-borda);
}
.estado-vazio__titulo {
  font-size: var(--texto-lg);
  color: var(--cor-texto);
  margin-bottom: 8px;
}
.estado-vazio__descricao {
  font-size: var(--texto-sm);
  margin-bottom: 20px;
}

/* =============================================================
   LOADING
   ============================================================= */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--cor-borda);
  border-top-color: var(--cor-principal);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
  display: inline-block;
}
.spinner--lg { width: 40px; height: 40px; border-width: 4px; }

@keyframes girar { to { transform: rotate(360deg); } }

.carregando {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px;
}
