/**
 * Modern Gallery Styles
 * Elegant, responsive, and smooth
 */

/* Gallery Container */
.modern-gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
}

/* Main Gallery */
#gallery-main {
  width: 100%;
  height: 600px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  background: #000;
  margin-bottom: 20px;
  position: relative;
}

#gallery-main .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

#gallery-main .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

#gallery-main .swiper-slide:hover img {
  transform: scale(1.02);
}

/* Loading State */
#gallery-main .swiper-slide img.swiper-lazy {
  opacity: 0;
  transition: opacity 0.6s ease;
}

#gallery-main .swiper-slide img.swiper-lazy-loaded {
  opacity: 1;
}

/* Navigation Buttons */
.gallery-button-prev,
.gallery-button-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  color: white;
  font-size: 24px;
  font-weight: 300;
}

.gallery-button-prev {
  left: 20px;
}

.gallery-button-next {
  right: 20px;
}

.gallery-button-prev:hover,
.gallery-button-next:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.gallery-button-prev::after {
  content: '‹';
}

.gallery-button-next::after {
  content: '›';
}

.swiper-button-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Pagination */
.gallery-pagination {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  padding: 8px 16px;
  border-radius: 20px 20px 0 0;
  font-size: 14px;
  font-weight: 500;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
}

/* Thumbnail Gallery */
#gallery-thumbs {
  width: 100%;
  height: 120px;
  border-radius: 15px;
  /* overflow-y: visible so scaled active thumb isn't clipped */
  overflow-x: hidden;
  overflow-y: visible;
  padding: 10px 0;
}

#gallery-thumbs .swiper-slide {
  width: 120px;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.3s ease;
  border: 3px solid transparent;
  position: relative;
}

#gallery-thumbs .swiper-slide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

#gallery-thumbs .swiper-slide:hover::before {
  opacity: 1;
}

#gallery-thumbs .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#gallery-thumbs .swiper-slide:hover {
  opacity: 0.8;
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#gallery-thumbs .swiper-slide-thumb-active,
#gallery-thumbs .swiper-slide.active-thumb {
  opacity: 1;
  border-color: #e5e7eb;
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(229, 231, 235, 0.6);
}

/* Image Info Overlay (optional) */
.gallery-image-info {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#gallery-main:hover .gallery-image-info {
  opacity: 1;
}

/* Loading Spinner */
.swiper-lazy-preloader {
  width: 42px;
  height: 42px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -21px;
  margin-top: -21px;
  z-index: 10;
  transform-origin: 50%;
  animation: swiper-preloader-spin 1s infinite linear;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  border-top-color: #fff;
}

@keyframes swiper-preloader-spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #gallery-main {
    height: 400px;
    border-radius: 15px;
    margin-bottom: 15px;
  }

  .gallery-button-prev,
  .gallery-button-next {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .gallery-button-prev {
    left: 10px;
  }

  .gallery-button-next {
    right: 10px;
  }

  .gallery-pagination {
    bottom: 0px;
    padding: 6px 12px;
    font-size: 12px;
  }

  #gallery-thumbs {
    height: 95px;
  }

  #gallery-thumbs .swiper-slide {
    width: 90px;
    height: 70px;
    border-radius: 8px;
    border-width: 2px;
  }

  .gallery-image-info {
    font-size: 11px;
    padding: 8px 12px;
    top: 10px;
    left: 10px;
  }
}

@media (max-width: 480px) {
  #gallery-main {
    height: 300px;
    border-radius: 12px;
  }

  #gallery-thumbs {
    height: 70px;
  }

  #gallery-thumbs .swiper-slide {
    width: 70px;
    height: 55px;
  }

  .modern-gallery-container {
    padding: 0 10px;
  }
}

/* PhotoSwipe Custom Styling */
.pswp {
  z-index: 99999;
}

/* Fix: PhotoSwipe's .pswp__zoom-wrap has position:absolute with width/height:auto.
   With all-absolute children, the zoom-wrap gets 0 intrinsic width, causing
   the actual images inside it to have offsetWidth=0 and render invisible in
   Chrome/Edge.  Switching actual images (not placeholders) to position:relative
   puts them in normal flow, gives the zoom-wrap real dimensions, and makes them
   render correctly.  Placeholders are position:absolute inside .pswp__item and
   are unaffected by this rule. */
.pswp__zoom-wrap .pswp__img:not(.pswp__img--placeholder) {
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
  display: block !important;
  opacity: 1 !important;
}

.pswp__bg {
  background: rgba(0, 0, 0, 0.95);
}

.pswp__top-bar {
  box-sizing: border-box;
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  width: 100% !important;
  max-width: 100vw;
}

.pswp__button {
  background: rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(10px);
  border-radius: 50% !important;
  transition: all 0.3s ease !important;
}

.pswp__button:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  transform: scale(1.1);
}

/* Smooth Entrance Animation */
@keyframes fadeInGallery {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modern-gallery-container {
  animation: fadeInGallery 0.8s ease-out;
}

/* Accessibility */
.gallery-button-prev:focus,
.gallery-button-next:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* High Quality Image Indicator */
.hq-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(74, 158, 255, 0.9);
  backdrop-filter: blur(10px);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  z-index: 10;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Click to view hint */
.click-hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#gallery-main:hover .click-hint {
  opacity: 1;
}
