/* cms-product.css — 产品页视频 & 多图样式 */

/* 产品媒体区域 — 默认隐藏，有内容时JS显示，编辑模式始终显示 */
.product-media-section {
  display: none;
  width: 100%;
  padding: 1.2rem 1.5rem;
  border-top: 1px solid #f0ece8;
  background: #fcfbf9;
  flex-shrink: 0;
}

/* 编辑模式下始终显示 */
body.cms-editing .product-media-section {
  display: block;
}

@media (max-width: 768px) {
  .product-media-section {
    padding: 1rem 1.2rem;
    display: none;
  }
  body.cms-editing .product-media-section {
    display: block;
  }
}

.product-media-label {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.6rem;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* 产品视频 */
.product-video-wrapper {
  margin-bottom: 1rem;
}

.product-video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #f0e6dc;
  border-radius: 8px;
}

.product-video-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

.product-video-container:has(video) {
  padding-bottom: 0;
  background: transparent;
  overflow: hidden; /* 防止 blur-bg 溢出遮挡下方编辑栏 */
}

.product-video-container .video-blur-bg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 120%; height: 120%;
  object-fit: cover;
  filter: blur(30px) brightness(0.6) saturate(1.2);
  z-index: 0;
  pointer-events: none;
}

.product-video-container video.foreground-video {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 50vh;
  display: block;
  margin: 0 auto;
  border-radius: 6px;
  background: transparent;
  object-fit: contain;
}

@media (max-width: 768px) {
  .product-video-container video.foreground-video {
    max-height: 40vh;
  }
  .product-video-container .video-blur-bg {
    height: 140%; width: 140%;
    filter: blur(20px) brightness(0.6) saturate(1.2);
  }
}

.product-video-placeholder {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0e6dc, #e6d5c8);
  color: #bbb;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.product-video-placeholder:hover {
  background: linear-gradient(135deg, #ebe0d5, #dfd0c0);
}

.product-video-placeholder .play-icon {
  font-size: 2rem;
  color: #c4956a;
  margin-bottom: 0.3rem;
}

.product-video-edit-bar {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0;
  position: relative;
  z-index: 10;
}

.product-video-edit-btn {
  padding: 0.3rem 0.8rem;
  border: 1px solid #c4956a;
  background: white;
  color: #c4956a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.product-video-edit-btn:hover {
  background: #c4956a;
  color: white;
}

.product-video-delete-btn {
  border-color: #e74c3c;
  color: #e74c3c;
}

.product-video-delete-btn:hover {
  background: #e74c3c;
  color: white;
}

/* ===== 产品图片：横排滚动展示 ===== */
.product-gallery {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.8rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: #c4956a #f5f0eb;
  -webkit-overflow-scrolling: touch;
}

.product-gallery::-webkit-scrollbar {
  height: 6px;
}
.product-gallery::-webkit-scrollbar-track {
  background: #f5f0eb;
  border-radius: 3px;
}
.product-gallery::-webkit-scrollbar-thumb {
  background: #c4956a;
  border-radius: 3px;
}

@media (max-width: 768px) {
  .product-gallery {
    gap: 0.5rem;
    padding: 0.3rem 0;
  }
}

.product-gallery-item {
  position: relative;
  flex: 0 0 auto;
  width: 160px;
  height: 160px;
  border-radius: 10px;
  overflow: hidden;
  background: #f5f0eb;
  cursor: pointer;
  transition: transform 0.2s;
}

@media (max-width: 768px) {
  .product-gallery-item {
    width: 130px;
    height: 130px;
  }
}

.product-gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.product-gallery-item:hover img {
  transform: scale(1.05);
}

/* 编辑按钮：桌面端 hover 显示，移动端始终可见 */
.product-gallery-item .gallery-delete {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  background: rgba(231,76,60,0.85);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  padding: 0;
  line-height: 1;
  z-index: 2;
}

.product-gallery-item .gallery-replace {
  position: absolute;
  top: 6px; right: 36px;
  width: 26px; height: 26px;
  background: rgba(196,149,106,0.85);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  padding: 0;
  line-height: 1;
  z-index: 2;
}

@media (hover: hover) {
  .product-gallery-item .gallery-delete,
  .product-gallery-item .gallery-replace {
    opacity: 0;
  }
  .product-gallery-item:hover .gallery-delete,
  .product-gallery-item:hover .gallery-replace {
    opacity: 1;
  }
}

@media (hover: none) {
  .product-gallery-item .gallery-delete,
  .product-gallery-item .gallery-replace {
    opacity: 1;
  }
}

.product-gallery-add {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #ddd;
  border-radius: 10px;
  color: #ccc;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 160px;
  height: 160px;
  user-select: none;
  gap: 0.3rem;
}

@media (max-width: 768px) {
  .product-gallery-add {
    width: 130px;
    height: 130px;
  }
}

.product-gallery-add:hover {
  border-color: #c4956a;
  color: #c4956a;
  background: #faf5f0;
}

.product-gallery-add .add-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* 非编辑模式隐藏编辑按钮 */
body:not(.cms-editing) .product-video-edit-bar,
body:not(.cms-editing) .product-gallery-add,
body:not(.cms-editing) .gallery-delete,
body:not(.cms-editing) .gallery-replace {
  display: none !important;
}

/* 编辑模式下：视频编辑栏始终显示 */
body.cms-editing .product-video-edit-bar {
  display: flex !important;
}