/* ===== CARRINHO (painel lateral) — usado na home e na página de produto ===== */
#carrinho-fundo {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10,10,10,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#carrinho-fundo.aberto { opacity: 1; pointer-events: auto; }

#carrinho-painel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 201;
  width: min(420px, 100vw);
  background: var(--card-bg, #fff);
  border-left: 1px solid var(--border, #e0e0e0);
  display: flex; flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;   /* el scroll no se contagia a la página */
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
#carrinho-painel.aberto { transform: translateX(0); }

.carrinho-topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--border, #e0e0e0);
  flex-shrink: 0;
}
.carrinho-topo h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem; font-weight: 700; margin: 0;
}
.carrinho-topo button {
  background: none; border: none; cursor: pointer;
  font-size: 1.7rem; line-height: 1; color: var(--text2, #444);
}

/* El panel entero es el que scrollea, y el footer queda pegado abajo con
   sticky. Antes el cuerpo era `flex: 1` con su propio scroll: cuando el footer
   creció (campo de CEP + aviso de pieza única) se quedaba con las migajas —
   medido: 221 px de cuerpo contra 384 px de footer en una ventana de 605 px —
   y los ítems del carrito quedaban prácticamente invisibles. */
#carrinho-corpo {
  flex: 0 0 auto;
  padding: 0.6rem 1.3rem;
  /* Que siempre se vea al menos un ítem entero (129 px) más el borde del
     siguiente, para que se entienda que hay más y se puede scrollear. */
  min-height: 150px;
}

.carrinho-vazio {
  padding: 2.5rem 0; text-align: center;
  color: var(--text2, #444); font-size: 0.9rem;
}

.carrinho-item {
  display: grid; grid-template-columns: 76px 1fr; gap: 0.9rem;
  padding: 1rem 0; border-bottom: 1px solid var(--border, #e0e0e0);
}
.carrinho-item img {
  width: 76px; height: 96px; object-fit: cover; border-radius: 3px;
  background: var(--bg2, #f9f8f6);
}
.carrinho-item-nome {
  font-size: 0.9rem; font-weight: 700; text-decoration: none;
  color: var(--text, #0a0a0a); display: block; line-height: 1.3;
}
.carrinho-item-nome:hover { color: var(--gold, #c9a84c); }
.carrinho-item-cod { font-size: 0.7rem; color: var(--text2, #444); opacity: 0.75; margin: 0.15rem 0; }
.carrinho-item-preco { font-size: 0.95rem; font-weight: 700; color: var(--gold, #c9a84c); margin: 0.3rem 0; }

.carrinho-qtd { display: flex; align-items: center; gap: 0.4rem; }
.carrinho-qtd button {
  width: 26px; height: 26px; cursor: pointer;
  border: 1px solid var(--border, #e0e0e0); background: var(--bg, #fff);
  color: var(--text, #0a0a0a); font-size: 0.95rem; line-height: 1;
}
.carrinho-qtd button:hover { border-color: var(--gold, #c9a84c); }
.carrinho-qtd span { min-width: 26px; text-align: center; font-size: 0.9rem; }
.carrinho-qtd .carrinho-remover {
  width: auto; padding: 0 0.5rem; margin-left: auto;
  font-size: 0.72rem; letter-spacing: 0.04em; color: var(--text2, #444);
  border: none; background: none; text-decoration: underline;
}
.carrinho-qtd .carrinho-remover:hover { color: #b3261e; }

#carrinho-rodape {
  flex-shrink: 0; padding: 1.1rem 1.3rem;
  border-top: 1px solid var(--border, #e0e0e0);
  background: var(--bg2, #f9f8f6);
  /* Pegado al fondo mientras los ítems scrollean detrás: el botón de
     finalizar nunca queda fuera de vista, y tampoco le roba altura al
     listado. `margin-top: auto` lo empuja abajo cuando hay pocos ítems. */
  position: sticky;
  bottom: 0;
  margin-top: auto;
}
.carrinho-topo {
  position: sticky;
  top: 0;
  background: var(--card-bg, #fff);
  z-index: 1;
}
.carrinho-subtotal {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.92rem; margin-bottom: 0.5rem;
}
.carrinho-subtotal strong { font-size: 1.2rem; color: var(--gold, #c9a84c); }
/* CEP de entrega. Reemplaza al prompt() del navegador: varios lo bloquean,
   no validaba nada y en móvil no abría el teclado numérico. */
.carrinho-cep { margin: 0.9rem 0 0.4rem; }
.carrinho-cep label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2, #444);
  margin-bottom: 0.35rem;
}
.carrinho-cep input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border, #E0E0E0);
  border-radius: 2px;
  font-family: 'Lato', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.06em;
}
.carrinho-cep input:focus {
  outline: 2px solid var(--gold, #C9A84C);
  outline-offset: -1px;
}
.carrinho-cep-erro {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #C62828;
}

.carrinho-nota { font-size: 0.75rem; color: var(--text2, #444); margin-bottom: 0.8rem; }
.carrinho-aviso {
  font-size: 0.78rem; line-height: 1.5;
  background: #fff6e0; border: 1px solid #e8d5a3; color: #6b5416;
  padding: 0.55rem 0.7rem; border-radius: 4px; margin-bottom: 0.8rem;
}
.btn-wpp-carrinho {
  display: block; text-align: center; text-decoration: none;
  margin-top: 0.55rem; padding: 0.75rem;
  background: var(--wa-green, #1a6b3a); color: #fff;
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
}
.btn-wpp-carrinho:hover { filter: brightness(0.92); }

/* Contador que se muestra sobre el ícono del carrito, en el header */
.carrinho-btn { position: relative; background: none; border: none; cursor: pointer; }
.carrinho-count {
  position: absolute; top: -6px; right: -8px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--gold, #c9a84c); color: #fff;
  border-radius: 9px; font-size: 0.68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
