/* ==========================================================================
   components.css — peças de UI reutilizáveis, independentes de onde
   aparecem na página (botão, card de item, contador, carrinho).
   Depende de base.css (variáveis). Media queries ficam junto do
   componente a que pertencem (mobile-first).
   ========================================================================== */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--dourado);
  color: var(--preto);
  box-shadow: 0 8px 20px rgba(201, 168, 118, 0.25);
}
.btn--primary:hover { background: var(--dourado-claro); }
.btn--primary:disabled {
  background: #3a3a3a;
  color: #7a7a7a;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.8;
}

.btn--ghost {
  background: transparent;
  color: var(--marrom-texto);
  border-color: var(--bege-escuro);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--marrom-suave); }

.btn--block { width: 100%; }

.icon { width: 1.1em; height: 1.1em; fill: currentColor; }

/* ---------- Card grande de item (foto de um lado, conteúdo do outro,
   alternando item a item — pedido explícito do usuário, referência de
   template escuro com seções alternadas). ---------- */
.menu-item {
  background: var(--branco);
  border: 1px solid var(--bege-escuro);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Foto do produto — opcional (ver js/menu-render.js e fotos/LEIA-ME.md).
   Fica `hidden` até a imagem carregar de verdade; sem foto, o elemento é
   removido do DOM e `.menu-item__conteudo` sozinho preenche a linha
   inteira — nada de retângulo vazio reservado. */
.menu-item__media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
}
.menu-item__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}
/* Sombreado sutil na base da foto — funde a imagem ao conteúdo escuro do
   card em vez de terminar num corte reto, mesmo em telas sem hover. */
.menu-item__media::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.menu-item.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.menu-item.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .menu-item.reveal { transition: none; }
}

@media (hover: hover) {
  /* Especificidade de propósito igual a `.menu-item.reveal.is-visible`
     (3 classes) + posição depois dela no arquivo — sem isso o `transform`
     da revelação por scroll vence o do hover depois que o card já
     apareceu (empate de especificidade, e quem vem antes perde), e o
     efeito de "levantar" no hover nunca se vê. */
  .menu-item.menu-item:hover {
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55);
    border-color: var(--dourado);
    transform: translateY(-3px);
  }
  .menu-item:hover .menu-item__media img { transform: scale(1.06); }
}

.menu-item__conteudo {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.9rem;
  padding: 1.6rem 1.5rem;
}

.menu-item__head {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.menu-item__name {
  font-family: var(--fonte-serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  line-height: 1.25;
  margin: 0;
  color: var(--marrom-texto);
}

.menu-item__unidade {
  font-family: var(--fonte-sans);
  font-style: normal;
  font-weight: 400;
  color: var(--marrom-suave);
  font-size: 0.82rem;
}

.menu-item__price {
  color: var(--dourado);
  font-weight: 700;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.menu-item__desc {
  margin: 0;
  color: var(--marrom-suave);
  font-size: 0.92rem;
  line-height: 1.65;
  max-width: 52ch;
}

.menu-item__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dourado-claro);
  background: rgba(184, 145, 47, 0.16);
  border: 1px solid rgba(184, 145, 47, 0.45);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

.menu-item__badge--off {
  color: #e2919c;
  background: rgba(156, 28, 43, 0.16);
  border-color: rgba(156, 28, 43, 0.45);
}

.menu-item__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--bege-escuro);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
}

.menu-item.is-indisponivel {
  opacity: 0.72;
}
.menu-item.is-indisponivel .stepper__btn { pointer-events: none; opacity: 0.35; }

/* A partir daqui a foto entra ao lado do conteúdo, alternando o lado
   item a item (`.menu-item--invertido`, atribuída em menu-render.js). */
@media (min-width: 700px) {
  .menu-item { flex-direction: row; align-items: stretch; min-height: 320px; }
  .menu-item--invertido { flex-direction: row-reverse; }
  .menu-item__media { flex: 1 1 46%; aspect-ratio: auto; }
  /* O degradê da base da foto existe para suavizar a emenda com o texto
     *abaixo* dela no empilhado mobile — lado a lado no desktop não tem
     essa emenda, então o degradê só escureceria a foto à toa. */
  .menu-item__media::after { display: none; }
  .menu-item__conteudo { flex: 1 1 54%; justify-content: center; padding: 2.25rem 2.5rem; }
}

/* ---------- Contador de quantidade (usado no card e no carrinho) ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--bege-escuro);
  border-radius: 999px;
  padding: 0.2rem 0.3rem;
}

.stepper__btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bege);
  color: var(--marrom-texto);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper__btn:hover { background: var(--dourado); color: var(--preto); }
.stepper__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper__btn:disabled:hover { background: var(--bege); color: var(--marrom-texto); }

.stepper__qty {
  min-width: 1.4rem;
  text-align: center;
  font-weight: 700;
}

/* ---------- Barra flutuante do carrinho ---------- */
.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(13, 13, 12, 0), var(--preto) 35%);
}

.cart-bar__button {
  width: 100%;
  max-width: var(--largura-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--dourado);
  color: var(--preto);
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

.cart-bar__count {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  min-width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.cart-bar__label { flex: 1; text-align: left; }

@media (min-width: 768px) {
  .cart-bar__button { max-width: 480px; }
}

/* ---------- Diálogo genérico (backdrop + painel) ----------
   Base do carrinho e da conta (login/registro/perfil) — mesmo padrão
   visual, reaproveitado em vez de duplicado. Cada diálogo tem seu próprio
   par de elementos no DOM (não compartilham estado), só a classe CSS. */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 90;
}

.dialog {
  position: fixed;
  right: 0;
  bottom: 0;
  top: auto;
  left: 0;
  max-height: 85vh;
  z-index: 100;
  background: var(--branco);
  border: 1px solid var(--bege-escuro);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  animation: slide-up 0.22s ease-out;
}

/* `display: flex` acima tem a mesma especificidade do `[hidden]{display:none}`
   do navegador, e regra de autor sempre vence a de user-agent — sem isto o
   atributo `hidden` seria ignorado e o diálogo apareceria aberto sozinho. */
.dialog[hidden] {
  display: none;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--bege-escuro);
}
.dialog__header h2 {
  font-family: var(--fonte-serif);
  font-style: italic;
  font-weight: 600;
  margin: 0;
  font-size: 1.4rem;
  color: var(--dourado);
}

.dialog__close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--marrom-suave);
  padding: 0.2rem 0.5rem;
}

.dialog__body {
  overflow-y: auto;
  padding: 0.5rem 1.25rem;
  flex: 1;
}

.cart-drawer__empty {
  color: var(--marrom-suave);
  text-align: center;
  padding: 2rem 0.5rem;
  font-size: 0.9rem;
}

.cart-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--bege-escuro);
}

.cart-line__info { flex: 1; min-width: 0; }
.cart-line__name { font-weight: 700; font-size: 0.92rem; margin: 0 0 0.15rem; color: var(--marrom-texto); }
.cart-line__unit-price { font-size: 0.78rem; color: var(--marrom-suave); margin: 0; }

.cart-line__price {
  font-weight: 700;
  color: var(--dourado);
  min-width: 4.5rem;
  text-align: right;
}

.dialog__footer {
  border-top: 1px solid var(--bege-escuro);
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--preto-cha);
}

.cart-drawer__entrega {
  border: none;
  margin: 0 0 0.9rem;
  padding: 0;
}
.cart-drawer__entrega legend {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--marrom-suave);
  margin-bottom: 0.5rem;
  padding: 0;
}
.cart-drawer__entrega-opcao {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1.25rem;
  font-size: 0.9rem;
  color: var(--marrom-texto);
  cursor: pointer;
}
.cart-drawer__entrega-opcao input {
  accent-color: var(--dourado);
  width: 16px;
  height: 16px;
}

.cart-drawer__subtotal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--marrom-suave);
  margin-bottom: 0.4rem;
}

.cart-drawer__total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.05rem;
  margin: 0.5rem 0 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--bege-escuro);
  color: var(--marrom-texto);
}
.cart-drawer__total-row strong { color: var(--dourado); font-size: 1.25rem; }

.cart-drawer__note {
  font-size: 0.76rem;
  color: var(--marrom-suave);
  text-align: center;
  margin: 0.65rem 0 0;
}

@media (min-width: 768px) {
  .dialog {
    left: auto;
    top: 0;
    width: 400px;
    max-height: 100vh;
    border-radius: 20px 0 0 20px;
    border-right: none;
    animation: slide-in 0.22s ease-out;
  }
  @keyframes slide-in {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialog { animation: none; }
}

/* ---------- Formulários dentro de diálogos (login/registro/perfil) ---------- */
.form-campo {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  text-align: left;
}
.form-campo label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--marrom-suave);
}
.form-campo input,
.form-campo select {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--bege-escuro);
  border-radius: 8px;
  background: var(--bege);
  color: var(--marrom-texto);
}
.form-campo input:focus,
.form-campo select:focus {
  outline: 2px solid var(--dourado);
  outline-offset: 1px;
}

.form-campo__ajuda {
  font-size: 0.76rem;
  color: var(--marrom-suave);
  font-weight: 400;
}

.form-erro {
  color: #f0a7b0;
  background: rgba(156, 28, 43, 0.16);
  border-left: 3px solid var(--vermelho);
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.form-sucesso {
  color: #8fd39a;
  background: rgba(56, 142, 60, 0.16);
  border-left: 3px solid #388e3c;
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.form-alternativa {
  text-align: center;
  font-size: 0.85rem;
  color: var(--marrom-suave);
  margin-top: 0.5rem;
}
.form-alternativa button {
  background: none;
  border: none;
  padding: 0;
  color: var(--dourado);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.perfil-resumo {
  text-align: center;
  margin-bottom: 1.25rem;
}
.perfil-resumo strong {
  display: block;
  font-family: var(--fonte-serif);
  font-size: 1.3rem;
  color: var(--dourado);
}
.perfil-resumo span {
  font-size: 0.82rem;
  color: var(--marrom-suave);
}
