/* 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; position: relative; }

.talle.talle-out {
  background: #ffe5e5;
  color: #c62828;
  opacity: 0.75;
}

.talle.talle-out::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  border-top: 2px solid #c62828;
  transform: translateY(-50%);
}

/* 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); }

#wa-menu a:hover { background: #f5f5f5; }

/* 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;
}

/* Estilos para modal de productos alternativos */
.alternativas-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.alternativas-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
}

.alternativas-modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  position: relative;
}

.alternativas-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #eee;
}

.alternativas-modal-header h2 {
  margin: 0;
  font-size: 22px;
  color: #333;
}

.alternativas-modal-close {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  line-height: 1;
}

.alternativas-modal-close:hover {
  background: #f0f0f0;
}

.alternativas-modal-body {
  margin-bottom: 20px;
}

.alternativas-modal-message {
  font-size: 16px;
  color: #666;
  margin-bottom: 20px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #CD844D;
}

.alternativas-empty {
  text-align: center;
  padding: 40px;
  color: #666;
}

.alternativas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.alternativa-card {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.alternativa-card:hover {
  border-color: #CD844D;
  box-shadow: 0 4px 12px rgba(205, 132, 77, 0.2);
  transform: translateY(-2px);
}

.alternativa-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.alternativa-info {
  flex: 1;
  margin-bottom: 12px;
}

.alternativa-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
}

.alternativa-meta {
  font-size: 14px;
  color: #666;
  margin: 4px 0;
}

.alternativa-colores {
  font-size: 12px;
  color: #999;
  font-style: italic;
  margin: 4px 0;
}

.alternativa-precio {
  font-size: 18px;
  font-weight: 600;
  color: #CD844D;
  margin: 8px 0 4px 0;
}

.alternativa-stock {
  font-size: 13px;
  color: #28a745;
  font-weight: 600;
  margin: 4px 0;
}

.alternativa-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.alternativa-tag {
  background: #f0f0f0;
  color: #666;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.alternativa-select-btn {
  width: 100%;
  padding: 10px 16px;
  background: #CD844D;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
  margin-top: auto;
}

.alternativa-select-btn:hover {
  background: #b86f3d;
}

.alternativas-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 2px solid #eee;
}

.alternativas-cerrar-btn {
  padding: 10px 24px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}

.alternativas-cerrar-btn:hover {
  background: #5a6268;
}

@media (max-width: 768px) {
  .alternativas-grid {
    grid-template-columns: 1fr;
  }
  
  .alternativas-modal-content {
    max-width: 95%;
    padding: 16px;
  }
}

/* Estilos para ofertas y promociones */
.price-original {
  text-decoration: line-through;
  color: #888;
  font-size: 0.9em;
  margin-right: 8px;
  opacity: 0.7;
}

.price-offer {
  color: #d33;
  font-weight: bold;
  font-size: 1.1em;
}

.offer-badge, .promo-badge {
  background: #CD844D;
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.promo-badge {
  background: #28a745; /* Green for promotions */
}

.oferta-chip {
  background: #CD844D !important;
  color: white !important;
}

.promo-chip {
  background: #28a745 !important;
  color: white !important;
}

/* Estilos para cards de oferta */
.offer-card {
  transition: all 0.3s ease;
  overflow: hidden;
}

.offer-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(255, 152, 0, 0.3);
  border-color: #ff6f00 !important;
}

.offer-card:active {
  transform: translateY(-2px);
}

.offer-card img {
  transition: transform 0.3s ease;
}

.offer-card:hover img {
  transform: scale(1.05);
}

/* Asegurar que los cards de oferta tengan el mismo tamaño que los productos */
.offer-card {
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .offer-card {
    min-height: 300px;
  }
}

/* Modal de producto con SKU */
.product-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  overflow-y: auto;
}

.product-modal.active {
  display: flex;
}

.product-modal-content {
  position: relative;
  max-width: 1200px;
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  width: 100%;
}

.product-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: #666;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 10;
}

.product-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

body.modal-open {
  overflow: hidden;
}

.product-modal-main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.product-modal-images {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.product-modal-main-image {
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  background: #f8f8f8;
}

.product-modal-gallery {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-modal-gallery .miniatura {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.product-modal-gallery .miniatura:hover {
  border-color: #CD844D;
}

.product-modal-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.product-modal-info h2 {
  margin: 0;
  font-size: 24px;
  color: #333;
}

.product-modal-description {
  color: #666;
  line-height: 1.6;
}

.product-modal-price-container {
  font-size: 20px;
  font-weight: 600;
  color: #CD844D;
}

.product-modal-colors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-modal-colors .color-btn {
  padding: 8px 16px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.product-modal-colors .color-btn:hover {
  border-color: #CD844D;
  background: #fff8f0;
}

.product-modal-colors .color-btn.selected {
  border-color: #CD844D;
  background: #CD844D;
  color: white;
}

.product-modal-variants {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-modal-variants .variant {
  padding: 16px;
  background: #f8f8f8;
  border-radius: 8px;
}

.product-modal-variants .talles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.product-modal-variants .talle {
  padding: 6px 12px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.product-modal-variants .talle:hover:not(.talle-out) {
  border-color: #CD844D;
  background: #fff8f0;
}

.product-modal-variants .talle.selected {
  border-color: #CD844D;
  background: #CD844D;
  color: white;
}

.product-modal-variants .talle.talle-out {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: line-through;
}

.product-modal-variants .reserve-controls {
  margin-top: 12px;
}

.product-modal-variants .reserve-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.product-modal-variants .reserve-controls select,
.product-modal-variants .reserve-controls input {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.product-modal-variants .reserve-btn {
  padding: 8px 20px;
  background: #CD844D;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.product-modal-variants .reserve-btn:hover:not(:disabled) {
  background: #B8734A;
}

.product-modal-variants .reserve-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .product-modal-main-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .product-modal-content {
    padding: 16px;
    max-height: 95vh;
  }
  
  .product-modal-main-image {
    max-height: 400px;
  }
} 