/* ============================================================
   components.css — Componentes: tarjetas, badges, carrito, popup
   ============================================================ */

/* — Tarjeta de producto — */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  will-change: transform;
  contain: layout style;
  position: relative;
}
.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

/* Fila de badge + alerta de stock */
.card-badge-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }

/* Badge de categoría */
.cat-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 50px;
  font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.cat-vino      { background: #FEE2E2; color: #9B1C1C; }
.cat-cerveza   { background: #FEF9C3; color: #854D0E; }
.cat-gin       { background: #EDE9FE; color: #5B21B6; }
.cat-vodka     { background: #DBEAFE; color: #1E40AF; }
.cat-whisky    { background: #FEF3C7; color: #92400E; }
.cat-fernet    { background: #D1FAE5; color: #065F46; }
.cat-aperitivo { background: #FCE7F3; color: #831843; }
.cat-default   { background: var(--primary-light); color: var(--primary-dark); }

/* Badge "Últimas X unidades" */
.badge-poco {
  font-size: .65rem; font-weight: 700; padding: 3px 9px; border-radius: 50px;
  background: #FFF7ED; color: #C2410C;
  border: 1px solid rgba(244,162,97,.3);
  white-space: nowrap; flex-shrink: 0;
}

/* Info del producto */
.card-name {
  font-family: var(--font-head); font-weight: 600; font-size: .98rem;
  color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-brand { font-size: .78rem; color: var(--text-3); font-weight: 500; margin-top: 1px; }

/* Separador */
.card-divider { height: 1px; background: var(--border); margin: 2px 0; }

/* Pie de tarjeta: precio + botón */
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.card-price  { font-family: var(--font-head); font-size: 1.55rem; font-weight: 800; color: var(--price-color); letter-spacing: -.02em; line-height: 1; }

/* Botón agregar (+) */
.add-btn {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.add-btn:hover  { background: var(--accent-hover); transform: scale(1.12); box-shadow: 0 6px 20px rgba(231,111,81,.5); }
.add-btn:active { transform: scale(.96); }
.add-btn svg    { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.5; }

/* — Drawer del carrito — */
#cart-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(31,45,47,.5); backdrop-filter: blur(6px);
  z-index: 200; opacity: 0; transition: opacity var(--transition);
}
#cart-overlay.open { display: block; opacity: 1; }

#cart-drawer {
  position: fixed; top: 0; right: 0;
  width: min(420px, 100vw); height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 40px rgba(47,111,122,.12);
}
#cart-drawer.open { transform: none; }

.cart-head {
  padding: 20px 24px;
  background: var(--primary-dark);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-head h2 { font-family: var(--font-head); font-size: 1rem; font-weight: 700; color: #fff; letter-spacing: -.01em; }

.cart-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: var(--transition);
}
.cart-close:hover { background: rgba(255,255,255,.25); }

.cart-body { flex: 1; overflow-y: auto; padding: 16px 24px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

#cart-empty-msg { text-align: center; padding: 56px 0; color: var(--text-3); font-size: .9rem; }
#cart-empty-msg span { display: block; font-size: 2.2rem; margin-bottom: 10px; opacity: .5; }

/* Items del carrito */
.cart-item { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.cart-item:last-child { border-bottom: none; }
.ci-name     { font-size: .88rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.ci-unit     { font-size: .76rem; color: var(--text-3); }
.ci-controls { display: flex; align-items: center; gap: 8px; }

.qty-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text); font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.qty-val    { font-weight: 700; font-size: .9rem; min-width: 22px; text-align: center; }
.ci-subtotal{ margin-left: auto; font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--price-color); }
.ci-remove  { color: var(--text-3); font-size: .75rem; padding: 4px 6px; border-radius: 4px; transition: var(--transition); }
.ci-remove:hover { color: var(--accent-hover); background: #FEE2E2; }

/* Pie del carrito */
.cart-foot { padding: 16px 24px; border-top: 1.5px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
#cart-total { display: flex; justify-content: space-between; font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; color: var(--text); }
#cart-total span:last-child { color: var(--price-color); }
#cart-actions { display: none; flex-direction: column; gap: 8px; }

/* Botón WhatsApp */
#btn-whatsapp {
  padding: 14px; border-radius: var(--radius-btn);
  background: #25D366; color: #fff;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
  box-shadow: 0 3px 12px rgba(37,211,102,.35);
}
#btn-whatsapp:hover { background: #1da851; box-shadow: 0 5px 18px rgba(37,211,102,.45); }

/* Botón vaciar */
#btn-clear {
  padding: 10px; border-radius: var(--radius-btn);
  border: 1.5px solid var(--border); color: var(--text-2); font-size: .82rem;
  transition: var(--transition);
}
#btn-clear:hover { border-color: var(--accent-hover); color: var(--accent-hover); }

/* — Formulario de datos (nombre + entrega) — */
#datos-form { display: none; flex-direction: column; gap: 10px; }
#datos-form.visible { display: flex; }

.form-label { font-size: .75rem; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .88rem; color: var(--text);
  outline: none; transition: var(--transition);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* Opciones retiro/envío */
.entrega-opts { display: flex; gap: 8px; }
.entrega-opt {
  flex: 1; padding: 10px 8px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: .8rem; font-weight: 600; color: var(--text-2);
  text-align: center; cursor: pointer; transition: var(--transition);
}
.entrega-opt:hover  { border-color: var(--primary); color: var(--primary); }
.entrega-opt.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

#campo-direccion { display: none; flex-direction: column; gap: 4px; }

/* — Popup de promoción — */
#promo-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(31,45,47,.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  transition: opacity .3s;
}
#promo-overlay.hidden { opacity: 0; pointer-events: none; }

.promo-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px;
  max-width: 380px; width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  position: relative;
}
.promo-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: var(--transition);
}
.promo-close:hover { background: var(--border); }
.promo-emoji  { font-size: 2.8rem; margin-bottom: 12px; }
.promo-title  { font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.promo-desc   { font-size: .88rem; color: var(--text-2); line-height: 1.6; margin-bottom: 20px; }
.promo-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 28px; border-radius: var(--radius-btn);
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem;
  transition: var(--transition);
}
.promo-btn:hover { background: var(--primary-dark); }

/* — Error box — */
#error-box {
  display: none;
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: 12px; padding: 20px 24px;
  margin: 40px auto; max-width: 480px; text-align: center;
}
#error-box strong { font-family: var(--font-head); color: #991B1B; display: block; margin-bottom: 6px; }
.error-msg { font-size: .85rem; color: #B91C1C; }

/* — Loader — */
#loader { text-align: center; padding: 80px 24px; }
/* ── Ajuste de la card para el nuevo layout con carrusel ──── */

/* La card ahora tiene dos zonas: carrusel arriba + card-body abajo */
/* Sobreescribimos el padding original de .product-card */
.product-card {
  padding: 0;          /* El padding pasa a estar en .card-body */
  overflow: hidden;    /* Contiene el carrusel dentro del border-radius */
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Carrusel ──────────────────────────────────────────────── */

.card-carrusel {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--primary-light);
  flex-shrink: 0;
}

.carrusel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}

.carrusel-slide {
  min-width: 100%;
  height: 100%;
  overflow: hidden;
}

.carrusel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.img-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: .75rem;
  color: var(--text-3);
  background: var(--bg);
}

/* Placeholder sin fotos */
.card-img-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  flex-shrink: 0;
}
.card-img-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: .6;
}

/* Botones ‹ › del carrusel */
.carrusel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.88);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
  transition: background var(--transition), opacity var(--transition);
  z-index: 2;
  color: var(--text);
  opacity: 0;
}
.card-carrusel:hover .carrusel-btn { opacity: 1; }
.carrusel-prev { left: 7px; }
.carrusel-next { right: 7px; }
.carrusel-btn:hover { background: #fff; }

/* Dots de posición */
.carrusel-dots {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}
.carrusel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition), transform var(--transition);
}
.carrusel-dot.activo {
  background: #fff;
  transform: scale(1.35);
}

/* En mobile los botones siempre visibles (no hay hover) */
@media (max-width: 768px) {
  .carrusel-btn { opacity: .8; }
}

/* ── Badge de subcategoría ──────────────────────────────────── */

.badge-subcategoria {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 9px;
  margin-top: 2px;
  max-width: fit-content;
}
