/* ========== LIGHTBOX ZOOM DE IMÁGENES ========== */

/* Contenedor principal del lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999; /* Por encima del modal (1050) */
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
}

.lightbox.is-open {
  display: flex;
  opacity: 1;
}

/* Contenedor de la imagen */
.lightbox__content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  animation: lightbox-zoom-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes lightbox-zoom-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Imagen principal */
.lightbox__img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  cursor: zoom-out;
  user-select: none;
  -webkit-user-drag: none;
}

/* Botón cerrar */
.lightbox__close {
  position: absolute;
  top: -50px;
  right: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  line-height: 1;
  padding: 0;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(90deg);
}

/* Botones de navegación (anterior/siguiente) */
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  z-index: 10;
}

.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-50%) scale(1.1);
}

.lightbox__nav:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox__nav--prev {
  left: 20px;
}

.lightbox__nav--next {
  right: 20px;
}

/* Ocultar navegación si solo hay una imagen */
.lightbox__nav.is-hidden {
  display: none;
}

/* Contador de imágenes */
.lightbox__counter {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Indicador de zoom */
.lightbox__zoom-hint {
  position: absolute;
  top: -50px;
  left: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fade-in-out 3s ease-in-out;
}

@keyframes fade-in-out {
  0%, 100% { opacity: 0; }
  10%, 90% { opacity: 1; }
}

.lightbox__zoom-hint::before {
  content: "🔍";
  font-size: 1.2rem;
}

/* Spinner de carga */
.lightbox__loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.lightbox.is-loading .lightbox__loader {
  display: block;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========== RESPONSIVE ========== */

/* Tablet */
@media (max-width: 880px) {
  .lightbox__close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .lightbox__nav {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .lightbox__nav--prev {
    left: 10px;
  }

  .lightbox__nav--next {
    right: 10px;
  }

  .lightbox__counter {
    bottom: 10px;
    font-size: 0.85rem;
  }

  .lightbox__zoom-hint {
    display: none;
  }
}

/* Móvil */
@media (max-width: 680px) {
  .lightbox__img {
    max-width: 95vw;
    max-height: 85vh;
  }

  .lightbox__close {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }

  .lightbox__nav {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .lightbox__counter {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
  }
}

/* Móvil pequeño */
@media (max-width: 480px) {
  .lightbox__content {
    max-width: 100vw;
    max-height: 100vh;
  }

  .lightbox__img {
    max-width: 100vw;
    max-height: 90vh;
    border-radius: 0;
  }

  .lightbox__close {
    top: 5px;
    right: 5px;
  }

  .lightbox__nav--prev {
    left: 5px;
  }

  .lightbox__nav--next {
    right: 5px;
  }
}

/* ========== ACCESIBILIDAD ========== */

/* Focus visible */
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__content,
  .lightbox__close,
  .lightbox__nav {
    animation: none;
    transition: none;
  }

  .lightbox__close:hover {
    transform: none;
  }

  .lightbox__nav:hover {
    transform: translateY(-50%);
  }
}

/* Dark mode support (opcional para futuro) */
@media (prefers-color-scheme: light) {
  .lightbox {
    background: rgba(255, 255, 255, 0.95);
  }

  .lightbox__close,
  .lightbox__nav {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.3);
    color: #000;
  }

  .lightbox__close:hover,
  .lightbox__nav:hover {
    background: rgba(0, 0, 0, 0.2);
  }

  .lightbox__counter {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border-color: rgba(0, 0, 0, 0.2);
  }
}
