/* ===========================
   LIGHTBOX CORREGIDO - DISEÑO RESPONSIVO
   =========================== */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 2rem;
}

.lightbox-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #fff;
}

/* Botón cerrar - Posicionado de forma segura */
.lightbox-close {
  position: absolute;
  top: -60px;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #333;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 4001;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
  background: #fff;
  transform: scale(1.1) rotate(90deg);
  color: #c4a76d;
}

/* Controles de navegación - Diseño mejorado */
.lightbox-controls {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 4001;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.lightbox-controls:hover {
  background: #fff;
  color: #c4a76d;
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
  left: -70px;
}

.lightbox-next {
  right: -70px;
}

/* Información adicional */
.lightbox-caption {
  margin-top: 1rem;
  color: #fff;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  max-width: 100%;
  line-height: 1.4;
}

.lightbox-counter {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.lightbox-gallery-indicator {
  position: absolute;
  top: -50px;
  left: 0;
  background: rgba(196, 167, 109, 0.9);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.lightbox-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #c4a76d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

/* Tablets (768px y menor) */
@media (max-width: 768px) {
  .lightbox-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: 1rem;
  }

  .lightbox-image {
    max-height: 70vh;
  }

  /* Reposicionar botones para tablets */
  .lightbox-close {
    top: 10px;
    right: 10px;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }

  .lightbox-prev {
    left: 10px;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }

  .lightbox-next {
    right: 10px;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }

  .lightbox-counter {
    bottom: 10px;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .lightbox-gallery-indicator {
    top: 10px;
    left: 10px;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .lightbox-caption {
    font-size: 1rem;
    margin-top: 0.75rem;
  }
}

/* Móviles (480px y menor) */
@media (max-width: 480px) {
  .lightbox-content {
    max-width: 98vw;
    max-height: 98vh;
    margin: 0.5rem;
  }

  .lightbox-image {
    max-height: 65vh;
    border-radius: 4px;
  }

  /* Botones más compactos para móviles */
  .lightbox-close {
    top: 5px;
    right: 5px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .lightbox-controls {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .lightbox-prev {
    left: 5px;
  }

  .lightbox-next {
    right: 5px;
  }

  .lightbox-counter {
    bottom: 5px;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .lightbox-gallery-indicator {
    top: 5px;
    left: 5px;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .lightbox-caption {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
  }
}

/* Móviles muy pequeños (320px y menor) */
@media (max-width: 320px) {
  .lightbox-content {
    margin: 0.25rem;
  }

  .lightbox-image {
    max-height: 60vh;
  }

  .lightbox-close,
  .lightbox-controls {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .lightbox-caption {
    font-size: 0.8rem;
  }

  .lightbox-counter,
  .lightbox-gallery-indicator {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Landscape móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .lightbox-content {
    max-height: 95vh;
  }

  .lightbox-image {
    max-height: 80vh;
  }

  .lightbox-close {
    top: 2px;
    right: 2px;
  }

  .lightbox-counter {
    bottom: 2px;
  }

  .lightbox-gallery-indicator {
    top: 2px;
    left: 2px;
  }

  .lightbox-caption {
    margin-top: 0.25rem;
    font-size: 0.8rem;
  }
}

/* Optimizaciones para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
  .lightbox-close,
  .lightbox-controls {
    min-width: 44px;
    min-height: 44px;
  }

  .lightbox-close:hover,
  .lightbox-controls:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.95);
  }

  .lightbox-close:active,
  .lightbox-controls:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 1);
  }
}

/* Estados de carga */
.lightbox-image[style*="display: none"] + .lightbox-loading {
  display: flex;
}

.lightbox-image:not([style*="display: none"]) + .lightbox-loading {
  display: none;
}

/* Accesibilidad */
.lightbox-close:focus,
.lightbox-controls:focus {
  outline: 2px solid #c4a76d;
  outline-offset: 2px;
}

/* Prevenir zoom en iOS */
@media (max-width: 480px) {
  .lightbox {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }
}

/* Asegurar que el contenido no se desborde */
.lightbox-content * {
  box-sizing: border-box;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .lightbox {
    background: rgba(0, 0, 0, 0.98);
  }
  
  .lightbox-close,
  .lightbox-controls {
    background: rgba(40, 40, 40, 0.9);
    color: #fff;
  }
  
  .lightbox-close:hover,
  .lightbox-controls:hover {
    background: rgba(60, 60, 60, 0.9);
    color: #c4a76d;
  }
}

/* ===========================
   MODAL IMAGEN COMPLETA - COMPATIBLE
   =========================== */

.modal-imagen-completa {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
}

.modal-imagen-completa.active {
  display: flex;
  opacity: 1;
}

.modal-imagen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.modal-imagen-content {
  position: relative;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 2rem;
}

.modal-imagen-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #fff;
}

.modal-imagen-close {
  position: absolute;
  top: -60px;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #333;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 4001;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.modal-imagen-close:hover {
  background: #fff;
  transform: scale(1.1) rotate(90deg);
  color: #c4a76d;
}

.modal-imagen-caption {
  margin-top: 1rem;
  color: #fff;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  max-width: 100%;
  line-height: 1.4;
}

/* Responsive para modal-imagen-completa */
@media (max-width: 768px) {
  .modal-imagen-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: 1rem;
  }

  .modal-imagen-content img {
    max-height: 70vh;
  }

  .modal-imagen-close {
    top: 10px;
    right: 10px;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }

  .modal-imagen-caption {
    font-size: 1rem;
    margin-top: 0.75rem;
  }
}

@media (max-width: 480px) {
  .modal-imagen-content {
    max-width: 98vw;
    max-height: 98vh;
    margin: 0.5rem;
  }

  .modal-imagen-content img {
    max-height: 65vh;
    border-radius: 4px;
  }

  .modal-imagen-close {
    top: 5px;
    right: 5px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .modal-imagen-caption {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
  }
}

@media (max-width: 320px) {
  .modal-imagen-content {
    margin: 0.25rem;
  }

  .modal-imagen-content img {
    max-height: 60vh;
  }

  .modal-imagen-close {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .modal-imagen-caption {
    font-size: 0.8rem;
  }
}

/* Landscape móviles para modal-imagen */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-imagen-content {
    max-height: 95vh;
  }

  .modal-imagen-content img {
    max-height: 80vh;
  }

  .modal-imagen-close {
    top: 2px;
    right: 2px;
  }

  .modal-imagen-caption {
    margin-top: 0.25rem;
    font-size: 0.8rem;
  }
}

/* Touch optimizations para modal-imagen */
@media (hover: none) and (pointer: coarse) {
  .modal-imagen-close {
    min-width: 44px;
    min-height: 44px;
  }

  .modal-imagen-close:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.95);
  }

  .modal-imagen-close:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 1);
  }
}

.modal-imagen-close:focus {
  outline: 2px solid #c4a76d;
  outline-offset: 2px;
}
