/* Contenedor principal de la galería */
.wc-gallery-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Grid de imágenes estilo Instagram */
.wc-gallery-carousel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  /* Eliminar propiedades de carrusel */
  overflow: visible;
  scroll-behavior: initial;
  padding: 0;
  scrollbar-width: initial;
  scrollbar-color: initial;
  height: auto;
  min-height: auto;
}

/* Items de la galería - Grid cuadrado */
.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1; /* Mantener cuadrado perfecto */
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-item:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-color: rgba(0, 123, 255, 0.3);
}

/* Estilos específicos para las imágenes del grid - Sobrescribir WooCommerce */
.wc-gallery-image,
.gallery-thumb {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  float: none !important;
  vertical-align: top !important;
}

/* Ocultar botones del carrusel ya que no los necesitamos en grid */
.carousel-btn {
  display: none;
}

/* Modal - Mantener funcionalidad existente */
.gallery-modal {
  display: none;
  position: fixed;
  z-index: 999999 !important;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  animation: fadeIn 0.3s ease;
}

.gallery-modal.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  text-align: center;
  z-index: 1000000 !important;
}

/* Estilos específicos para la imagen del modal - Mantener original */
.wc-gallery-modal-image,
.modal-content img {
  max-width: 100% !important;
  max-height: 80vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  border-radius: 0.625rem !important;
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.5) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  float: none !important;
  vertical-align: top !important;
  display: block !important;
}

/* Botón cerrar modal */
.modal-close {
  position: absolute;
  top: -3.125rem;
  right: 0;
  color: white;
  font-size: 2.5rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 1000001 !important;
  width: 3.125rem;
  height: 3.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  transition: background-color 0.3s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Botones de navegación del modal */
.modal-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 3.4375rem;
  height: 3.4375rem;
  border-radius: 50%;
  font-size: 1.75rem;
  cursor: pointer;
  z-index: 1000001 !important;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-50%) scale(1.1);
}

.modal-prev {
  left: -5rem;
}

.modal-next {
  right: -5rem;
}

/* Container para modales */
#wc-gallery-modal-container {
  pointer-events: none;
}

#wc-gallery-modal-container .gallery-modal {
  pointer-events: all;
}

/* Responsive Design para Grid */

/* Pantallas muy grandes - 4 columnas */
@media (min-width: 1200px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

/* Pantallas grandes - 4 columnas con menos gap */
@media (min-width: 992px) and (max-width: 1199px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
}

/* Tablets - 3 columnas */
@media (min-width: 768px) and (max-width: 991px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .wc-gallery-container {
    padding: 15px;
  }
}

/* Tablets pequeñas - 3 columnas */
@media (min-width: 576px) and (max-width: 767px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  .wc-gallery-container {
    padding: 10px;
  }
  
  .modal-btn {
    width: 3.125rem;
    height: 3.125rem;
    font-size: 1.5rem;
  }

  .modal-prev {
    left: 0.9375rem;
  }

  .modal-next {
    right: 0.9375rem;
  }

  .modal-close {
    top: 0.9375rem;
    right: 0.9375rem;
    font-size: 2.1875rem;
  }
}

/* Móviles - 2 columnas */
@media (max-width: 575px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }
  
  .wc-gallery-container {
    padding: 8px;
  }
  
  .gallery-item {
    border-radius: 6px;
  }
  
  .modal-btn {
    width: 2.8125rem;
    height: 2.8125rem;
    font-size: 1.25rem;
  }
  
  .modal-prev {
    left: 10px;
  }

  .modal-next {
    right: 10px;
  }

  .modal-close {
    top: 10px;
    right: 10px;
    font-size: 2rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Móviles muy pequeños - 2 columnas más compactas */
@media (max-width: 400px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
  
  .wc-gallery-container {
    padding: 5px;
  }
  
  .gallery-item {
    border-radius: 4px;
  }
}

/* Orientación landscape en móviles - mantener 3 columnas */
@media (orientation: landscape) and (max-height: 500px) {
  .wc-gallery-carousel {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

/* Ajustes de márgenes para diferentes tamaños */
@media (max-width: 980px) {
  .wc-gallery-container {
    margin-top: -20px;
    margin-bottom: -20px;
  }
}

@media (min-width: 981px) {
  .wc-gallery-container {
    margin-top: -2%;
    margin-bottom: -2%;
  }
}

/* Efecto hover mejorado para touch devices */
@media (hover: none) {
  .gallery-item:hover {
    transform: none;
  }
  
  .gallery-item:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}