/**
 * 现代化商品图片灯箱样式
 * 类似 autosverschueren.be 的灯箱效果
 */

/* 灯箱主容器 */
.product-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-lightbox.active {
  opacity: 1;
  visibility: visible;
}

/* 背景遮罩 */
.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(2px);
}

/* 灯箱容器 */
.lightbox-container {
  position: relative;
  width: 90%;
  height: 90%;
  max-width: 1200px;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* 关闭按钮 */
.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

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

/* 主图显示区域 */
.lightbox-main-image {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  overflow: hidden;
  border-radius: 8px;
}

.lightbox-main-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.3s ease;
  border-radius: 8px;
}

/* 加载状态 */
.lightbox-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

.lightbox-loading.active {
  display: block;
}

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

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

  100% {
    transform: rotate(360deg);
  }
}

/* 导航按钮 */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 5;
}

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

.lightbox-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox-nav:disabled:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-50%);
}

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

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

/* 图片信息 */
.lightbox-info {
  position: absolute;
  top: -50px;
  left: 0;
  color: white;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  text-align: center;
}

.lightbox-counter {
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* 底部缩略图导航 */
.lightbox-thumbnails {
  height: 80px;
  overflow: hidden;
  position: relative;
}

.lightbox-thumbnails-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  overflow-x: auto;
  scroll-behavior: smooth;
  height: 100%;
  align-items: center;
}

/* 隐藏滚动条但保持功能 */
.lightbox-thumbnails-container::-webkit-scrollbar {
  display: none;
}

.lightbox-thumbnails-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.lightbox-thumbnail {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.lightbox-thumbnail:hover {
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-thumbnail.active {
  border-color: #ffffff;
  transform: scale(1.1);
}

.lightbox-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .lightbox-container {
    width: 95%;
    height: 95%;
  }

  .lightbox-close {
    top: -40px;
    width: 35px;
    height: 35px;
  }

  .lightbox-nav {
    width: 40px;
    height: 40px;
  }

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

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

  .lightbox-info {
    top: -40px;
    font-size: 12px;
  }

  .lightbox-thumbnails {
    height: 60px;
  }

  .lightbox-thumbnail {
    width: 45px;
    height: 45px;
  }
}

@media (max-width: 480px) {
  .lightbox-nav {
    position: fixed;
    top: auto;
    bottom: 100px;
    transform: none;
  }

  .lightbox-prev {
    left: 20px;
  }

  .lightbox-next {
    right: 20px;
  }

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

  .lightbox-info {
    top: 20px;
    left: 20px;
  }
}

/* 键盘焦点样式 */
.lightbox-nav:focus,
.lightbox-close:focus,
.lightbox-thumbnail:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* 动画效果 */
.lightbox-main-image img.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {

  .lightbox-nav:hover,
  .lightbox-close:hover,
  .lightbox-thumbnail:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.1);
  }

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

/* 主图悬停提示 */
#main-product-image::after {
  content: 'Click to view full size';
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.main-product-image:hover #main-product-image::after {
  opacity: 1;
}

/* 缩略图悬停提示 */
.thumbnail-item::before {
  content: 'Double-click to open lightbox';
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 8px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

.thumbnail-item:hover::before {
  opacity: 1;
}

/* 移动端隐藏提示 */
@media (max-width: 768px) {

  #main-product-image::after,
  .thumbnail-item::before {
    display: none;
  }
}

/* 只隐藏WordPress核心的交互式灯箱，保留我们自己的灯箱系统 */
[data-wp-interactive="core/image"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* 当我们的产品灯箱打开时，确保WordPress核心灯箱被隐藏 */
body:has(.product-lightbox.active) [data-wp-interactive="core/image"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* 防止WooCommerce原生灯箱的干扰 */
.woocommerce-product-gallery__trigger {
  display: none !important;
}