/* ==========================================================================
   FRUTALIA — cart.css
   Carrito multi-producto: botón de carrito en el header, drawer lateral
   flotante en vidrio esmerilado y variante "Consultar Disponibilidad"
   para productos sin precio publicado. Compartido por tienda.html y
   producto.html; reutiliza las variables de marca de css/styles.css
   (--verde, --naranja, --texto-*, --radius-*, --font-*).
   ========================================================================== */

/* --------------------------------------------------------------------
   Botón de carrito (header)
   -------------------------------------------------------------------- */
.cart-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(62, 142, 79, 0.12);
  color: var(--verde-oscuro);
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  margin-left: 6px;
}
.cart-toggle:hover, .cart-toggle:focus-visible {
  background: var(--verde);
  color: #fff;
  transform: translateY(-2px);
}
.cart-toggle svg { width: 22px; height: 22px; }

.cart-toggle__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--naranja-fuerte);
  color: #fff;
  font-family: var(--font-titulos);
  font-weight: 700;
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --------------------------------------------------------------------
   Overlay
   -------------------------------------------------------------------- */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 20, 0.45);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 998;
}
.cart-overlay.is-visible { opacity: 1; pointer-events: auto; }

/* --------------------------------------------------------------------
   Drawer lateral (vidrio esmerilado)
   -------------------------------------------------------------------- */
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-left: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.18);
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: 24px;
}
/* La transición CSS es la que realmente mueve el panel (no depende de
   que GSAP haya cargado desde el CDN); GSAP solo suma el fade del
   overlay cuando está disponible, ver cart.js. */
.cart-drawer.is-open { transform: translateX(0); }
.cart-drawer:not(.is-open) { pointer-events: none; }

.cart-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.cart-drawer__title {
  font-family: var(--font-titulos);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--texto-principal);
  margin: 0;
}
.cart-drawer__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--texto-principal);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.25s ease;
}
.cart-drawer__close:hover, .cart-drawer__close:focus-visible { background: rgba(0, 0, 0, 0.12); }

.cart-drawer__hint {
  font-size: 0.76rem;
  color: var(--texto-suave);
  background: rgba(62, 142, 79, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 16px;
}

.cart-drawer__empty {
  color: var(--texto-suave);
  font-size: 0.9rem;
  text-align: center;
  margin: auto 0;
  padding: 24px 8px;
}

.cart-drawer__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cart-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  padding: 10px;
}
.cart-item__media {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-item__media img { width: 100%; height: 100%; object-fit: contain; }

.cart-item__name {
  font-family: var(--font-titulos);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--texto-principal);
  line-height: 1.25;
  margin: 0 0 2px;
}
.cart-item__unit-price {
  font-size: 0.72rem;
  color: var(--texto-suave);
  margin: 0 0 6px;
}
.cart-item__tier {
  display: inline-block;
  font-family: var(--font-titulos);
  font-weight: 700;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--texto-suave);
}
.cart-item__tier--mayorista { color: var(--verde-oscuro); }
.cart-item__qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cart-item__qty-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(62, 142, 79, 0.3);
  background: transparent;
  color: var(--verde-oscuro);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.cart-item__qty-btn:hover, .cart-item__qty-btn:focus-visible { background: var(--verde); color: #fff; }
.cart-item__qty-value {
  min-width: 18px;
  text-align: center;
  font-family: var(--font-titulos);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--texto-principal);
}

.cart-item__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.cart-item__subtotal {
  font-family: var(--font-titulos);
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--naranja-fuerte);
  margin: 0;
  white-space: nowrap;
}
.cart-item__remove {
  border: none;
  background: none;
  color: var(--texto-suave);
  font-size: 0.72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.cart-item__remove:hover, .cart-item__remove:focus-visible { color: var(--naranja-fuerte); }

.cart-drawer__footer {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 16px;
  margin-top: 16px;
}
.cart-drawer__total-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-titulos);
  font-size: 0.95rem;
  color: var(--texto-principal);
  margin: 0 0 14px;
}
.cart-drawer__total-row strong { color: var(--verde-oscuro); font-size: 1.2rem; }

.cart-drawer__checkout.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* --------------------------------------------------------------------
   Botón "Consultar Disponibilidad" — gris/azul acentuado, sin precio
   -------------------------------------------------------------------- */
.btn--consultar {
  background: #536878 !important;
  border-color: #536878 !important;
}
.btn--consultar:hover, .btn--consultar:focus-visible {
  background: #3C5568 !important;
  border-color: #3C5568 !important;
}

@media (max-width: 480px) {
  .cart-drawer { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-toggle, .cart-item__qty-btn, .cart-drawer__close { transition: none; }
}
