/* Reset y tipografías */
body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  background: #E5E1DC;
  color: #333;
}

header {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header img {
  height: 60px;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

/* Menú de categorías */
.menu {
  display: flex;
  justify-content: center;
  gap: .5rem;
  background: #fff;
  padding: .5rem;
  flex-wrap: wrap;
}

.menu button {
  padding: .5rem 1rem;
  font-size: .9rem;
  border: none;
  border-radius: 5px;
  background: #CD844D;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background-color .2s;
}

.menu button:hover {
  background: #b86f3d;
}

/* Contenedor filtro + botón de vista */
#filter-container {
  padding: 0 .5rem;
  background: #E5E1DC;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#filter-select {
  flex: 1;
  max-width: 60%;
  margin-right: 1rem;
  padding: .4rem .8rem;
  font-size: .9rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  display: block;
}

#view-toggle {
  padding: .5rem 1rem;
  font-size: .9rem;
  border: none;
  border-radius: 5px;
  background: #CD844D;
  color: #fff;
  cursor: pointer;
  transition: background-color .2s;
  flex: none;
}

#toggleFiltros {
  padding: .5rem 1rem;
  font-size: .9rem;
  border: none;
  border-radius: 5px;
  background: #CD844D;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s ease;
  flex: none;
}

#toggleFiltros:hover {
  background: #b86f3d;
}

.toggle-btn {
  background: #CD844D;
  color: white;
  border: none;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
}

.toggle-btn:hover {
  background: #b86f3d;
}

#view-toggle:hover {
  background: #b86f3d;
}

/* Grid de tarjetas */
#catalogo {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Vista compacta: 2 columnas fijas */
#catalogo.compact {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* Evitar que las tarjetas crezcan */
#catalogo .card {
  min-width: 0;
}

/* Tarjeta */
.card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.download-container {
  position: absolute;
  top: -8px;
  right: 2px;
  z-index: 2;
}

.download-btn {
  position: absolute;
  top: 30px;
  right: 22px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #CD844D;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease;
  z-index: 10;
}

.download-btn:hover {
  background: #b86f3d;
}

.download-btn img {
  width: 18px;
  height: 18px;
}

.download-btn svg {
  width: 30px;
  height: 30px;
  fill: white;
}

/* Imagen principal */
.main-image {
  display: block;
  width: 100%;
  border-radius: 10px;
  aspect-ratio: 4/5;
  object-fit: cover;
}

/* Galería de miniaturas */
.gallery {
  display: flex;
  gap: .4rem;
  margin-top: .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery img {
  flex: 0 0 auto;
  width: 60px;
  aspect-ratio: 4/5;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  scroll-snap-align: start;
}

/* Ajustes para compact */
#catalogo.compact .gallery {
  flex-wrap: nowrap;
  scroll-snap-type: x mandatory;
}

#catalogo.compact .gallery img {
  width: 48px;
}

/* Título, colores, descripción, precio, talles */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: .5rem 0;
}

.article-box {
  background: #eee;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .95rem;
}

.article-fire {
  margin-left: 4px;
  font-size: 1.1rem;
}

.colors {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.color-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: #CD844D;
  color: #fff;
  font-size: .85rem;
  cursor: pointer;
  transition: opacity .2s;
}

#btn-scroll-top {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: #333;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 999;
}

#btn-scroll-top svg {
  width: 24px;
  height: 24px;
}

#btn-scroll-top:hover {
  background: #f1f1f1;
}

#btn-scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.loader {
  text-align: center;
  padding: 2rem;
  font-size: 1rem;
  font-weight: bold;
  color: #CD844D;
  display: none;
}

.loader.show {
  display: block;
}

#search-container {
  padding: 0.5rem 1rem;
  background: #E5E1DC;
  text-align: center;
}

#searchInput {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  outline: none;
  transition: box-shadow 0.2s ease;
}

#searchInput:focus {
  box-shadow: 0 0 0 2px #CD844D33;
  border-color: #CD844D;
}

#filtroMenu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 1rem;
  background: #E5E1DC;
  border-radius: 8px;
  justify-content: flex-start;
}

#filtroMenu label {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
}

#filtroMenu label:hover {
  background-color: #f2f2f2;
}

#filtroMenu input[type="checkbox"] {
  display: none;
}

#filtroMenu input[type="checkbox"]:checked+span {
  background: #CD844D;
  color: #fff;
  border-color: #CD844D;
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
}

.menu button.active {
  background: white;
  color: #CD844D;
  border: 2px solid #CD844D;
}

.image-loader {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 0.5rem;
  display: none;
  z-index: 2;
}

.image-loader.active {
  display: block;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #ccc;
  border-top: 3px solid #CD844D;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.color-btn:hover {
  opacity: .8;
}

.description {
  font-size: .9rem;
  color: #555;
  margin-bottom: .4rem;
}

.price-container {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .4rem;
}

.price {
  font-weight: bold;
  color: #d33;
  font-size: 1rem;
}

.wholesale {
  font-size: .8rem;
  color: #777;
}

.variant {
  margin-top: .6rem;
}

.talles {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.talle {
  background: #eee;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .9rem;
}

/* WhatsApp popup */
#wa-popup {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
}

#wa-toggle {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#wa-toggle svg {
  width: 40px;
  height: 40px;
  fill: #fff;
}

#wa-toggle img {
  width: 40px;
  height: 40px;
}

#wa-menu {
  display: none;
  position: absolute;
  bottom: 60px;
  right: 0;
  background: white;
  padding: 0.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-direction: column;
  gap: 0.5rem;
}

#wa-menu.open {
  display: flex;
}

#wa-menu a {
  margin: .25rem 0;
  padding: .6rem 1rem;
  background: #76f1a3;
  border-radius: 4px;
  text-decoration: none;
  color: #000000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  display: inline-block;
  min-width: 160px;
  text-align: center;
}

#wa-menu a:hover {
  background: #f5f5f5;
}

/* Styles for wa-menu items (labels widened for Envios / Local (Resistencia)) */
/* Note: 'Ani' removed from the menu */

/* Modal PWA */
.install-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.install-modal.hidden {
  display: none;
}

.install-modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  max-width: 90%;
}

.install-modal-content p {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  color: #333;
}

.install-modal-content button {
  margin: 0 .5rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: 5px;
  font-size: .95rem;
  cursor: pointer;
}

#install-accept {
  background: #CD844D;
  color: #fff;
}

#install-later {
  background: #777;
  color: #fff;
}

/* Mejoras de UX */
.no-data,
.error-message {
  text-align: center;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  margin: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.error-message {
  color: #d33;
}

/* Mejoras de accesibilidad */
.card:focus-within {
  outline: 2px solid #CD844D;
  outline-offset: 2px;
}

.color-btn:focus,
.download-btn:focus {
  outline: 2px solid #CD844D;
  outline-offset: 2px;
}

/* Mejoras de rendimiento */
.main-image {
  will-change: transform;
  backface-visibility: hidden;
}

/* Mejoras de feedback visual */
.download-btn {
  position: relative;
  overflow: hidden;
}

.download-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.download-btn:active::after {
  width: 100%;
  height: 100%;
}

/* Mejoras de responsive */
@media (max-width: 480px) {
  .menu {
    padding: 0.5rem;
  }

  .menu button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  #catalogo {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.8rem;
    padding: 0.8rem;
  }
}

/* Mejoras de animaciones */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.3s ease-out;
}

/* Mejoras de scroll */
.smooth-scroll {
  scroll-behavior: smooth;
}

/* Mejoras de carga */
.image-loader {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.spinner {
  border-width: 2px;
}

/* Botón Ver más productos */
.see-more-container {
  grid-column: 1 / -1;
  text-align: center;
  margin: 2rem 0;
  width: 100%;
}

.btn-ver-mas {
  padding: .5rem 1rem;
  font-size: .9rem;
  border: none;
  border-radius: 5px;
  background: #CD844D;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background-color .2s;
}

.btn-ver-mas:hover {
  background: #b86f3d;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.visible {
  opacity: 1;
  visibility: visible;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.lightbox.visible img {
  transform: scale(1);
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 3rem;
  color: #fff;
  cursor: pointer;
  z-index: 3001;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#lightbox-close:hover {
  color: #CD844D;
}