.gallery-grid-wrapper {
  min-height: 100vh; /* Altura mínima del contenedor de la galería */
  display: flex;
  align-items: center; /* Centrado vertical si el contenido es bajo */
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem; /* Mayor espacio entre imágenes */
  max-width: 100%;
  margin: 0 auto;
  padding: 4rem 1rem; /* Más espacio arriba y abajo */
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #f8f9fa;
}

.selectable-img {
  width: 100%;
  height: 400px;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
  border: 3px solid transparent;
  border-radius: 8px;
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

.selectable-img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.selectable-img.selected {
  border-color: gold;
  box-shadow: 0 0 15px rgba(218, 165, 32, 0.8);
  transform: scale(1.05);
  cursor: zoom-in;
}

/* Responsive breakpoints */
@media (max-width: 576px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 2rem 0.5rem;
  }

  .selectable-img {
    height: 240px;
  }

  .container {
    padding: 0.5rem;
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .selectable-img {
    height: 280px;
  }
}

@media (min-width: 769px) and (max-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .selectable-img {
    height: 320px;
  }
}

@media (min-width: 993px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .selectable-img {
    height: 380px;
  }
}

/* Modal/Lightbox styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  font-size: 30px;
  color: white;
  cursor: pointer;
  z-index: 1001;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalZoomIn 0.3s ease-out;
}

.modal-navigation {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-counter {
  margin-top: 15px;
  color: white;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 15px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

@keyframes modalZoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .modal-container {
    max-width: 95%;
    max-height: 95%;
  }

  .modal-close {
    top: -30px;
    font-size: 24px;
    width: 35px;
    height: 35px;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .modal-img {
    max-height: 70vh;
  }
}

/* Prevenir scroll cuando modal está activo */
body.modal-active {
  overflow: hidden;
}

/* Galería con efecto decorativo */
.gallery-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 49%, rgba(255,255,255,0.1) 50%, transparent 51%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

.gallery-item:hover::before {
  opacity: 1;
}

/* Animación de entrada */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Margen lateral para todo el contenedor */
.margen-responsive {
  margin: 0 5cm;
}

@media (max-width: 767.98px) {
  .margen-responsive {
    margin: 0 1cm;
  }
}
