/* ============================================================
   ToystyleMall 商品图片展示统一优化
   作用域：商品卡片 / 首页商品卡 / 商品详情主图与详情图 / 灯箱
   ============================================================ */
:root {
  --ts-img-bg: #f7f8fb;
  --ts-img-radius: 12px;
}

/* 列表 / 搜索 / 品牌 / 相关商品：统一方形展示舞台，完整展示商品不裁切 */
.product-wrap .image {
  aspect-ratio: 1 / 1;
  background: var(--ts-img-bg) url('/image/catalog/brand/v2/product_placeholder.jpg') no-repeat center / 58% auto;
  border-radius: var(--ts-img-radius);
}
.product-wrap .image > a {
  display: block;
  width: 100%;
  height: 100%;
}
.product-wrap .image img.image-before,
.product-wrap .image img.image-after {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent;
}
.product-wrap .image > a .image-before { transition: transform .35s ease; }
.product-wrap:hover .image > a .image-before { transform: scale(1.04); }
.product-wrap.list .image {
  flex: 0 0 200px;
  width: 200px;
  height: 200px;
  aspect-ratio: auto;
}

/* 首页商品卡：由 cover 改为 contain，与搜索/分类一致，避免商品被裁切 */
.ts-home .ts-card {
  background: var(--ts-img-bg) url('/image/catalog/brand/v2/product_placeholder.jpg') no-repeat center / 58% auto;
}
.ts-home .ts-card img {
  object-fit: contain !important;
  background: transparent !important;
}

/* 商品详情页：主图方形舞台、缩略图统一、移动端轮播统一 */
body.page-product .product-image .left {
  flex: 0 0 84px;
  max-height: 528px;
}
body.page-product .product-image .left .swiper > div > div {
  width: 80px;
  height: 80px;
  min-height: 80px;
  padding: 2px;
  background: var(--ts-img-bg);
}
body.page-product .product-image .left .swiper > div > div > a img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
body.page-product .product-image .right {
  flex: 1;
  min-width: 0;
}
body.page-product .product-image .right .product-img {
  width: 100%;
  max-width: none;
  aspect-ratio: 1 / 1;
  background: var(--ts-img-bg) url('/image/catalog/brand/v2/product_placeholder.jpg') no-repeat center / 58% auto;
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
}
body.page-product .product-image .right .product-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  transition: transform .3s ease;
}
body.page-product .product-image .right .product-img:hover img { transform: scale(1.03); }
body.page-product .product-image #swiper-mobile .swiper-slide {
  aspect-ratio: 1 / 1;
  background: var(--ts-img-bg) url('/image/catalog/brand/v2/product_placeholder.jpg') no-repeat center / 58% auto;
  cursor: zoom-in;
}
body.page-product .product-image #swiper-mobile .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

/* 详情图：统一居中、圆角、懒加载占位与点击放大 */
.rich-text-editor-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 10px;
  border-radius: 8px;
  background: var(--ts-img-bg);
  cursor: zoom-in;
  transition: box-shadow .2s ease, transform .2s ease;
}
.rich-text-editor-content img:hover {
  box-shadow: 0 8px 24px rgba(31, 45, 77, .16);
  transform: translateY(-1px);
}
.rich-text-editor-content .ts-detail-gallery img { width: 100%; }
.rich-text-editor-content .ts-img-fallback { opacity: .9; }

/* 生成卡 V3：首图通栏 + 实拍图两列网格，统一方形完整展示 */
.ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
}
.ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid > p {
  margin: 0 !important;
  background: var(--ts-img-bg) url('/image/catalog/brand/v2/product_placeholder.jpg') no-repeat center / 58% auto !important;
  border-radius: 12px !important;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid > p.ts-detail-lead {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  max-height: 720px;
}
.ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid img {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: contain;
  background: transparent !important;
  border-radius: 0 !important;
}

/* 点击放大灯箱 */
#ts-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(12, 16, 30, .92);
  backdrop-filter: blur(4px);
}
#ts-lightbox.ts-open { display: flex; }
#ts-lightbox .ts-lb-img {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
#ts-lightbox .ts-lb-close {
  position: absolute;
  top: 20px;
  right: 26px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 28px;
  line-height: 44px;
  cursor: pointer;
}
#ts-lightbox .ts-lb-close:hover { background: rgba(255, 255, 255, .3); }
#ts-lightbox .ts-lb-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  padding: 0 20px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: .9;
}
#ts-lightbox .ts-lb-hint {
  position: absolute;
  top: 26px;
  left: 28px;
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
}
#ts-lightbox .ts-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 28px;
  line-height: 48px;
  cursor: pointer;
  display: none;
}
#ts-lightbox .ts-lb-nav:hover { background: rgba(255, 255, 255, .3); }
#ts-lightbox.has-multi .ts-lb-nav { display: block; }
#ts-lightbox .ts-lb-prev { left: 24px; }
#ts-lightbox .ts-lb-next { right: 24px; }
#ts-lightbox .ts-lb-count {
  position: absolute;
  top: 26px;
  right: 90px;
  color: rgba(255, 255, 255, .82);
  font-size: 14px;
  display: none;
}
#ts-lightbox.has-multi .ts-lb-count { display: block; }

@media (max-width: 768px) {
  .product-wrap .image { border-radius: 10px; }
  body.page-product .product-image .left { flex: 0 0 64px; }
  body.page-product .product-image .left .swiper > div > div {
    width: 60px;
    height: 60px;
    min-height: 60px;
  }
  .ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid { grid-template-columns: 1fr !important; }
  .ts-detail-gallery[data-ts-layout="grid"] .ts-detail-grid > p.ts-detail-lead { grid-column: auto !important; }
  #ts-lightbox { padding: 14px; }
  #ts-lightbox .ts-lb-img { max-width: 96vw; max-height: 82vh; }
  #ts-lightbox .ts-lb-hint { display: none; }
  #ts-lightbox .ts-lb-nav { width: 38px; height: 38px; line-height: 38px; font-size: 22px; }
  #ts-lightbox .ts-lb-prev { left: 8px; }
  #ts-lightbox .ts-lb-next { right: 8px; }
  #ts-lightbox .ts-lb-count { top: 18px; right: 70px; font-size: 12px; }
}
