/* ============================================================
   CARRITO
   ============================================================ */

.cart {
  position: fixed;
  top: 0;
  right: -100%;
  width: 320px;
  height: 100%;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.9);
  transition: 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: var(--z-cart);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
}

.cart.active {
  right: 0;
}

@media (max-width: 380px) {
  .cart {
    width: 100vw;
  }
}

/* HEADER */
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-6);
}

.cart-header h2 {
  font-size: var(--text-xl);
  letter-spacing: 2px;
}

.cart-close {
  cursor: pointer;
  font-size: var(--text-lg);
  transition: var(--t-fast);
}

.cart-close:hover {
  transform: scale(1.2);
}

/* ENVÍO GRATIS — barra de progreso hacia IGNIT_FREE_SHIPPING_THRESHOLD
   (ver js/config.js). Sin "display" propio a propósito: así el [hidden]
   por defecto del navegador basta para ocultarla con el carrito vacío o ya
   con envío gratis conseguido (ver notas de CSS del proyecto). */
.cart-free-shipping {
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cart-free-shipping-text {
  margin: 0 0 var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.cart-free-shipping-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

.cart-free-shipping.cart-free-shipping-done .cart-free-shipping-text {
  color: var(--text-primary);
}

.cart-free-shipping-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.cart-free-shipping-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--ignit-red-hov), var(--ignit-red));
  box-shadow: 0 0 12px var(--ignit-red-50);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-free-shipping.cart-free-shipping-done .cart-free-shipping-fill {
  background: linear-gradient(90deg, var(--ignit-red), #2ecc71);
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.45);
}

/* ITEMS */
.cart-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar acorde al tema oscuro (webkit) */
.cart-items::-webkit-scrollbar {
  width: 6px;
}

.cart-items::-webkit-scrollbar-track {
  background: transparent;
}

.cart-items::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

.cart-items::-webkit-scrollbar-thumb:hover {
  background: var(--ignit-red);
}

/* Scrollbar acorde al tema oscuro (firefox) */
.cart-items {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.cart-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3);
  transition: var(--t-fast);
}

.cart-item:hover {
  border-color: var(--border-strong);
}

.cart-item-img {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.cart-item-info {
  min-width: 0;
  flex: 1;
  /* Deja hueco a la derecha para no solapar con los controles en la
     esquina superior (basura + stepper +/-), que están posicionados
     en absoluto sobre la tarjeta. */
  padding-right: 52px;
}

.cart-item-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.cart-item-price {
  font-size: var(--text-sm);
  opacity: 0.6;
  margin-top: var(--sp-1);
}

.cart-item-qty {
  font-size: var(--text-xs);
  opacity: 0.75;
  margin-top: var(--sp-2);
}

/* ESQUINA SUPERIOR DERECHA: basura para eliminar + stepper +/- */
.cart-item-actions {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}

.cart-item-remove {
  /* <button> real, no <span onclick> — hay que anular el reset global de
     "button" (fondo rojo, ancho 100%, sombra...) definido en styles.css. */
  all: unset;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.cart-item-remove:hover {
  color: var(--ignit-red);
  background: var(--ignit-red-12);
}

.cart-item-remove:focus-visible {
  outline: 2px solid var(--ignit-red);
  outline-offset: 1px;
}

.cart-item-stepper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cart-item-stepper button {
  all: unset;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--t-fast);
  box-sizing: border-box;
}

.cart-item-stepper button:hover {
  background: var(--bg-glass);
}

.cart-item-stepper button:focus-visible {
  outline: 2px solid var(--ignit-red);
  outline-offset: -2px;
}

/* ICONO */
.cart-icon {
  position: relative;
  font-size: var(--text-xl);
  cursor: pointer;
  margin-left: var(--sp-2);
  margin-right: var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t-fast);
}

.cart-icon:hover {
  transform: scale(1.1);
}

.cart-icon:active {
  transform: scale(0.9);
}

/* SVG — transición de color cuando hay items */
.cart-svg {
  transition: color 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-icon.has-items .cart-svg {
  color: var(--ignit-red);
}

/* CONTADOR — número inline al lado del carrito */
#cart-count {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--ignit-red);
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  margin-left: 4px;
}

/* MARKETING OPT-IN */
.marketing-optin {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  cursor: pointer;
}

.marketing-optin input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.marketing-optin input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-fast), background var(--t-fast);
}

.marketing-optin input[type="checkbox"]:checked {
  background: var(--ignit-red-25);
  border-color: var(--ignit-red);
}

.marketing-optin input[type="checkbox"]:checked::before {
  transform: translateX(16px);
  background: var(--ignit-red);
}

.marketing-optin-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* TOTAL */
.cart-total {
  padding: var(--sp-4) 0;
  font-size: var(--text-base);
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: var(--sp-4);
}

/* CHECKOUT BTN */
.cart-checkout {
  width: 100%;
  padding: var(--sp-4);
  background: var(--ignit-red);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all var(--t-fast);
  text-transform: uppercase;
  margin-top: var(--sp-3);
}

.cart-checkout:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-btn-hov);
}
