/* === PRODUCT CARD STYLES === */
.category_product {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  /* padding: 12px; */
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  font-family: "Quicksand", sans-serif;
  flex: 0 0 auto; /* ✅ permite scroll horizontal en .scrollable */
  width: 95%; /* 🟢 para mobile: casi todo el viewport */
  max-width: 260px; /* 🟢 en desktop, no más que esto */
  margin: 0 auto;
  height: 100%;
  max-height: 500px;
  scroll-snap-align: start; /* ✅ para anclarse en scroll horizontal */
}
.category_product:hover {
  color: inherit;
  opacity: 1;
}
.category_grid.scrollable > .category_product {
  max-height: unset;
}
.card_top {
  display: flex;
  justify-content: center;
  font-size: 0.85rem;
  color: #333;
  padding: 0 6px;
  margin-bottom: 6px;
  font-weight: 700;
}

.card_product_id,
.card_product_name,
.card_product_price {
  user-select: text;
}

.category_product h4 {
  padding: 0 10px;
  font-weight: 400;
  line-height: 1.2em;
  min-height: 3.6em; /* fuerza el espacio de hasta 3 líneas */
  height: 100%;
  display: flex;
  align-items: center; /* centra el texto verticalmente */
  text-align: center;
  justify-content: center;
  font-size: 1rem;
  margin: 0;
}

.category_product .price {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 5px 0 8px 0;
}

.category_product .quantity_control {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  border: 1px solid #000;
  width: 100%;
  max-width: 160px;
  margin: 0 auto 6px;
}

.category_product .qty_btn {
  background: #f3f3f3;
  border: none;
  padding: 4px 0;
  font-size: 1rem;
  cursor: pointer;
  border-right: 1px solid #000;
  border-left: 1px solid #000;
  height: 100%;
}

.category_product .qty_input {
  width: 100%;
  text-align: center;
  border: none;
  padding: 4px 0;
  font-size: 0.95rem;
  background: #fff;
}

.category_product .add_btn {
  width: 100%;
  max-width: 160px;
  margin: 0 auto;
  padding: 6px 10px;
  border: 1px solid #000;
  background: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  position: relative;
}
.category_product .add_btn.disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
/* oculto solo el texto mientras carga */
.category_product .add_btn.disabled .btn-text {
  visibility: hidden;
}
.category_product .add_btn:hover {
  background: #000;
  color: #fff;
}
/* spinner centrado */
.category_product .add_btn.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor; /* usa el color del botón */
  border-right-color: transparent; /* sector transparente */
  border-radius: 50%;
  animation: btnspin 0.8s linear infinite;
}

.category_product .card_bottom {
  margin-top: auto; /* empuja hacia abajo */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
}
/* === PRODUCT LISTING SECTIONS === */
#sections_container {
  width: 100%;
}
.category_section {
  text-align: center;
  width: 100%;
  position: relative;
  padding-bottom: 3.5rem;
}
.category_section.has_background .section_title {
  color: #fff;
}

.section_img {
  position: absolute;
  inset: 0;
  object-fit: cover;
  z-index: -10;
}
.section_overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  z-index: -1;
}
/* === CARRUSEL / SCROLLABLE === */
.category_grid_wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  padding-bottom: 0;
  max-width: 1400px;
  margin: 0 auto;
}
.category_grid_wrapper:not(:has(.scrollable)) .scroll_arrow {
  display: none;
}
.category_grid.scrollable {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 1rem;
  gap: 1rem;
  padding: 0 2vw;
  padding-bottom: 1rem;
  width: 100%; /* ✔️ Esto limita el ancho al contenedor padre */
  max-width: 100vw; /* ✔️ Esto asegura que no se desborde */
  justify-content: flex-start;
}

.category_grid.scrollable::-webkit-scrollbar {
  display: none; /* oculta scroll en Chrome/Safari */
}

/* === GRILLA TRADICIONAL === */
.category_grid:not(.scrollable) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 30px 20px;
  width: 100%;
}

/* === FLECHAS === */
.scroll_arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  padding: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: opacity 0.3s ease;
  opacity: 1;
  display: none;
}
/* CARD PILL */
.in_cart_badge {
  margin-left: 8px;
  background: #eef6ff;
  color: #0b61d6;
  border: 1px solid #cfe4ff;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 12px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial;
}
.express_badge {
  position: absolute;
  bottom: 0;
  left: 0;
  color: #76b976ba;
  padding: 5px 18px;
  padding-bottom: 0;
  padding-left: 10px;
  border: 1px solid #8cd88cba;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background-color: #fff;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  user-select: none;
  opacity: 0.95;
  letter-spacing: 1.25px;
  border-left: 0;
  z-index: 10;
}

.express_badge .bx {
  position: absolute;
  top: 10%;
}
/* accesibilidad */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.qty_btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (min-width: 768px) {
  .scroll_arrow {
    display: inline-block;
  }
  .scroll_arrow.left {
    left: 2.5%;
    opacity: 0;
    transform: rotate(180deg);
  }

  .scroll_arrow.right {
    right: 2.5%;
  }
  .category_grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 30px 20px;
    justify-content: center;
  }

  .category_grid.scrollable .category_product {
    flex: 0 0 25%; /* 4 productos por vista */
  }
}

/* Contenedor de imagen con overlay */
.category_product .image_wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* ✅ cuadrado perfecto */
  overflow: hidden;
  border-radius: 6px;
  flex: 0 0 auto;
}

/* Pill arriba a la derecha */
.category_product .in_cart_badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 6px 10px;
  border-radius: 2px;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  user-select: none;
  opacity: 0.95;
}

/* Imagen centrada dentro del cuadrado */
.category_product .image_wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 4px;
  z-index: 0;
}
