/* Modal de imagen en pantalla completa */
.fullscreen-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.fullscreen-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.fullscreen-modal {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Botón cerrar flotante */
.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 10001;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Contenedor de imagen principal */
.fullscreen-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  padding: 70px 20px 120px;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
}

.fullscreen-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  /* Asegurar que imágenes verticales no se recorten */
  object-position: center;
}

/* Botones de navegación */
.fullscreen-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  z-index: 10000;
}

.fullscreen-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.fullscreen-nav--prev {
  left: 30px;
}

.fullscreen-nav--next {
  right: 30px;
}

/* Carrusel de thumbnails */
.fullscreen-thumbnails {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  padding: 15px;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.thumbnails-container {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  padding: 0 5px;
}

.thumbnails-container::-webkit-scrollbar {
  display: none;
}

/* Mostrar máximo 3 thumbnails en pantallas grandes */
@media (min-width: 769px) {
  .thumbnails-container {
    max-width: 300px;
    justify-content: center;
  }
  
  .thumbnail-wrapper:nth-child(n+4) {
    display: none;
  }
}

/* En móviles, permitir scroll horizontal */
@media (max-width: 768px) {
  .thumbnails-container {
    justify-content: flex-start;
    padding: 0 10px;
  }
}

.thumbnail-wrapper {
  flex-shrink: 0;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.thumbnail-wrapper.active {
  border-color: #00d4aa;
  box-shadow: 0 0 20px rgba(0, 212, 170, 0.4);
}

.thumbnail-image {
  width: 80px;
  height: 60px;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 6px;
}

.thumbnail-wrapper:hover .thumbnail-image {
  transform: scale(1.05);
}

.thumbnail-wrapper:not(.active) .thumbnail-image {
  opacity: 0.7;
}

.thumbnail-wrapper:not(.active):hover .thumbnail-image {
  opacity: 1;
}

/* Responsive Design */

/* Tablets y pantallas medianas */
@media (max-width: 1024px) {
  .fullscreen-close {
    width: 48px;
    height: 48px;
    font-size: 19px;
  }

  .fullscreen-nav {
    width: 55px;
    height: 55px;
    font-size: 22px;
  }

  .fullscreen-nav--prev {
    left: 25px;
  }

  .fullscreen-nav--next {
    right: 25px;
  }

  .thumbnail-image {
    width: 75px;
    height: 56px;
  }
}

/* Móviles grandes y tablets pequeñas */
@media (max-width: 768px) {
  .fullscreen-close {
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  .fullscreen-nav {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .fullscreen-nav--prev {
    left: 15px;
  }

  .fullscreen-nav--next {
    right: 15px;
  }

  .fullscreen-image-container {
    padding: 55px 15px 100px;
    box-sizing: border-box;
  }

  .fullscreen-thumbnails {
    bottom: 15px;
    padding: 12px;
    max-width: calc(100vw - 30px);
  }

  .thumbnails-container {
    max-width: none;
    gap: 8px;
  }

  .thumbnail-image {
    width: 60px;
    height: 45px;
  }
}

/* Móviles medianos */
@media (max-width: 480px) {
  .fullscreen-close {
    top: 12px;
    right: 12px;
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .fullscreen-nav {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  .fullscreen-nav--prev {
    left: 12px;
  }

  .fullscreen-nav--next {
    right: 12px;
  }

  .fullscreen-image-container {
    padding: 50px 12px 90px;
    box-sizing: border-box;
  }

  .fullscreen-thumbnails {
    bottom: 10px;
    padding: 10px;
    max-width: calc(100vw - 24px);
  }

  .thumbnails-container {
    gap: 6px;
  }

  .thumbnail-image {
    width: 50px;
    height: 38px;
  }
}

/* Móviles pequeños */
@media (max-width: 360px) {
  .fullscreen-close {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    font-size: 14px;
  }

  .fullscreen-nav {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .fullscreen-nav--prev {
    left: 10px;
  }

  .fullscreen-nav--next {
    right: 10px;
  }

  .fullscreen-image-container {
    padding: 45px 10px 80px;
    box-sizing: border-box;
  }

  .fullscreen-thumbnails {
    bottom: 8px;
    padding: 8px;
    max-width: calc(100vw - 20px);
  }

  .thumbnails-container {
    gap: 4px;
  }

  .thumbnail-image {
    width: 45px;
    height: 34px;
  }
}

/* Orientación horizontal en móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .fullscreen-image-container {
    padding: 15px 50px 60px;
    box-sizing: border-box;
  }

  .fullscreen-thumbnails {
    bottom: 3px;
    padding: 4px 8px;
    border-radius: 8px;
  }

  .thumbnail-image {
    width: 35px;
    height: 26px;
  }

  .fullscreen-close {
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .fullscreen-nav {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .fullscreen-nav--prev {
    left: 5px;
  }

  .fullscreen-nav--next {
    right: 5px;
  }

  .thumbnails-container {
    gap: 3px;
    padding: 0 3px;
  }
}

/* Pantallas muy pequeñas en altura (landscape extremo) */
@media (max-height: 400px) and (orientation: landscape) {
  .fullscreen-thumbnails {
    display: none;
  }

  .fullscreen-image-container {
    padding: 10px 40px 10px;
    box-sizing: border-box;
  }
}

/* Optimización específica para imágenes verticales */
.fullscreen-image[data-orientation="vertical"],
.fullscreen-image.vertical-image {
  max-width: 90vw;
  max-height: calc(100vh - 200px);
  width: auto !important;
  height: auto !important;
}

@media (max-width: 768px) {
  .fullscreen-image[data-orientation="vertical"],
  .fullscreen-image.vertical-image {
    max-width: 95vw;
    max-height: calc(100vh - 180px);
  }
}

@media (max-width: 480px) {
  .fullscreen-image[data-orientation="vertical"],
  .fullscreen-image.vertical-image {
    max-width: 95vw;
    max-height: calc(100vh - 160px);
  }
}

/* Touch optimizations para móviles */
@media (hover: none) and (pointer: coarse) {
  .fullscreen-nav,
  .fullscreen-close,
  .thumbnail-image {
    min-height: 44px;
    min-width: 44px;
  }

  .thumbnail-wrapper {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Prevenir scroll del body cuando el modal está activo */
body.modal-active {
  overflow: hidden;
}
