/*--------------------------------------------------------------
# CUSTOM LIGHTBOX SYSTEM (GLIGHTBOX REPLACEMENT)
--------------------------------------------------------------*/

/* Lightbox Overlay */
.custom-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-lightbox.active {
  opacity: 1;
  visibility: visible;
}

/* Lightbox Container */
.lightbox-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  margin: auto;
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-lightbox.active .lightbox-container {
  transform: scale(1);
}

/* Lightbox Content */
.lightbox-content {
  position: relative;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  max-height: 100%;
}

.lightbox-content img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lightbox-content video {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
}

/* Iframe content */
.lightbox-content iframe {
  width: 80vw;
  height: 80vh;
  border: none;
  border-radius: 8px;
}

/* Close Button */
.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #333;
  transition: all 0.3s ease;
  z-index: 10001;
}

.lightbox-close:hover {
  background: white;
  transform: scale(1.1);
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Navigation Arrows */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: all 0.3s ease;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
}

.custom-lightbox.has-navigation .lightbox-nav {
  opacity: 1;
  visibility: visible;
}

.lightbox-nav:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
}

.lightbox-nav.prev {
  left: -70px;
}

.lightbox-nav.next {
  right: -70px;
}

.lightbox-nav svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Counter */
.lightbox-counter {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: #333;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-lightbox.has-navigation .lightbox-counter {
  opacity: 1;
  visibility: visible;
}

/* Title/Description */
.lightbox-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 40px 20px 20px;
  font-size: 16px;
  line-height: 1.4;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.lightbox-content:hover .lightbox-title {
  transform: translateY(0);
}

/* Loading Spinner */
.lightbox-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-left: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Zoom functionality */
.lightbox-content.zoomable {
  cursor: zoom-in;
}

.lightbox-content.zoomed {
  cursor: zoom-out;
  transform: scale(2);
  transition: transform 0.3s ease;
}

/* Gallery thumbnails */
.lightbox-thumbnails {
  position: absolute;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  max-width: 80vw;
  overflow-x: auto;
  padding: 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-lightbox.show-thumbnails .lightbox-thumbnails {
  opacity: 1;
  visibility: visible;
}

.lightbox-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.lightbox-thumbnail:hover,
.lightbox-thumbnail.active {
  opacity: 1;
  border-color: white;
  transform: scale(1.1);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .lightbox-container {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .lightbox-content iframe {
    width: 90vw;
    height: 60vh;
  }
  
  .lightbox-close {
    top: -40px;
    width: 36px;
    height: 36px;
  }
  
  .lightbox-nav {
    width: 44px;
    height: 44px;
  }
  
  .lightbox-nav.prev {
    left: -55px;
  }
  
  .lightbox-nav.next {
    right: -55px;
  }
  
  .lightbox-counter {
    bottom: -40px;
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .lightbox-thumbnails {
    bottom: -60px;
    max-width: 90vw;
  }
  
  .lightbox-thumbnail {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 480px) {
  .lightbox-nav {
    display: none;
  }
  
  .lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
  }
  
  .lightbox-counter {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
  }
  
  .lightbox-content {
    border-radius: 0;
  }
  
  .lightbox-container {
    max-width: 100vw;
    max-height: 100vh;
  }
}

/* Touch gestures indicators */
.lightbox-touch-hint {
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.custom-lightbox.show-touch-hint .lightbox-touch-hint {
  opacity: 1;
}

/* Animation classes */
.lightbox-fade-in {
  animation: lightboxFadeIn 0.3s ease-out;
}

.lightbox-fade-out {
  animation: lightboxFadeOut 0.3s ease-out;
}

@keyframes lightboxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes lightboxFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .custom-lightbox {
    background: black;
  }
  
  .lightbox-close,
  .lightbox-nav,
  .lightbox-counter {
    background: white;
    color: black;
    border: 2px solid black;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .custom-lightbox,
  .lightbox-container,
  .lightbox-close,
  .lightbox-nav,
  .lightbox-counter,
  .lightbox-thumbnails {
    transition: none;
  }
  
  .lightbox-fade-in,
  .lightbox-fade-out {
    animation: none;
  }
}