.product-gallery-template {
  position: relative;
  width: 100%;
  max-width: none;
  min-width: 0;
}

.product-gallery-template img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
}

.product-gallery-template .MagicZoom,
.product-gallery-template .mz-figure {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
  min-width: 0;
  line-height: 0;
}

.product-gallery-main,
.product-gallery-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: auto;
  min-height: 260px;
  overflow: visible !important;
  background: #fff;
  box-sizing: border-box;
}

.product-gallery-main .MagicZoom,
.product-gallery-frame .MagicZoom {
  display: block !important;
  flex: 1 1 auto;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-width: 0;
}

.product-gallery-template .mz-figure img,
.product-gallery-main img,
.product-gallery-frame img {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
  max-height: none !important;
  object-fit: contain;
  object-position: center;
}

.product-gallery-main .mz-figure,
.product-gallery-frame .mz-figure {
  width: 100% !important;
  height: auto !important;
}

.product-gallery-template-1 .product-gallery-main {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.product-gallery-template-2 .product-gallery-main {
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 8px;
}

.product-gallery-template-2 {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.product-gallery-template-2 .product-gallery-main {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  padding: 8px;
  border-color: #ececec;
  border-radius: 14px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.07);
}

.product-gallery-template-2 .product-gallery-thumbs-2 {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  margin-top: 0 !important;
  min-height: 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper {
  height: auto;
  max-height: 450px;
  padding: 28px 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-wrapper {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: none !important;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail {
  flex: 0 0 78px;
  width: 78px !important;
  height: 78px;
  margin-right: 0 !important;
  border-radius: 10px;
}

.product-gallery-template-4 .MagicZoom {
  padding: 7px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
}

.product-gallery-template-3 {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.product-gallery-template-3 .product-gallery-main {
  grid-column: 2;
  grid-row: 1;
  padding: 8px;
  border: 1px solid #ededed;
  border-radius: 14px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.06);
}

.product-gallery-template-3 .product-gallery-thumbs {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  margin-top: 0 !important;
  min-height: 0;
}

.product-gallery-template-3 .product-gallery-thumbs .swiper {
  height: auto;
  max-height: 450px;
  padding: 28px 0;
}

.product-gallery-template-3 .product-gallery-thumbs .swiper-wrapper {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: none !important;
}

.product-gallery-template-3 .product-gallery-thumbs .thumb-pro-detail {
  flex: 0 0 78px;
  width: 78px !important;
  height: 78px;
  margin-right: 0 !important;
  border-radius: 10px;
}

.product-gallery-template-4 .product-gallery-frame {
  padding: 14px;
  border: 5px solid #b61f24;
  border-radius: 15px;
}

.product-gallery-template-1 .product-gallery-main .MagicZoom,
.product-gallery-template-2 .product-gallery-main .MagicZoom {
  display: block !important;
  height: auto !important;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.product-gallery-template-1 .product-gallery-main .mz-figure,
.product-gallery-template-2 .product-gallery-main .mz-figure {
  width: 100%;
  height: auto !important;
  max-height: none !important;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.product-gallery-template-1 .product-gallery-main img,
.product-gallery-template-2 .product-gallery-main img {
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
  max-height: none !important;
  object-fit: contain;
}

.product-gallery-template-1 .album-product,
.product-gallery-thumbs,
.product-gallery-template-2 .product-gallery-thumbs-2 {
  position: relative;
  margin-top: 12px !important;
  min-height: 76px;
}

.product-gallery-template-1 .album-product .swiper,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper,
.product-gallery-thumbs .swiper {
  position: relative;
  width: 100%;
  padding: 0 38px;
  overflow: hidden;
  box-sizing: border-box;
}

.product-gallery-template .swiper-wrapper {
  align-items: stretch;
}

.product-gallery-template-1 .album-product .thumb-pro-detail,
.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail,
.product-gallery-thumbs .thumb-pro-detail {
  display: block !important;
  flex: 0 0 76px;
  width: 76px !important;
  height: 76px;
  aspect-ratio: 1 / 1;
  padding: 3px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
  cursor: pointer;
}

.product-gallery-template-1 .album-product .thumb-pro-detail img,
.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail img,
.product-gallery-thumbs .thumb-pro-detail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-gallery-template-1 .album-product .thumb-pro-detail.mz-thumb-selected,
.product-gallery-template-2
  .product-gallery-thumbs-2
  .thumb-pro-detail.mz-thumb-selected,
.product-gallery-thumbs .thumb-pro-detail.mz-thumb-selected {
  border-color: #999;
}

.product-gallery-thumbs-compact .swiper {
  padding: 0 38px;
}

.product-gallery-template-1 .album-product .swiper-button-prev,
.product-gallery-template-1 .album-product .swiper-button-next,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next,
.product-gallery-thumbs .swiper-button-prev,
.product-gallery-thumbs .swiper-button-next {
  width: 28px;
  height: 28px;
  margin-top: -14px;
  color: #333;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  z-index: 3;
}

.product-gallery-template-1 .album-product .swiper-button-prev,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev,
.product-gallery-thumbs .swiper-button-prev {
  left: 4px;
}

.product-gallery-template-1 .album-product .swiper-button-next,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next,
.product-gallery-thumbs .swiper-button-next {
  right: 4px;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next {
  left: 50%;
  right: auto;
  transform: translateX(-50%) rotate(90deg);
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev {
  top: 14px;
  margin-top: 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next {
  top: auto;
  bottom: 14px;
  margin-top: 0;
}

.product-gallery-template-1 .album-product .swiper-button-prev:after,
.product-gallery-template-1 .album-product .swiper-button-next:after,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev:after,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next:after,
.product-gallery-thumbs .swiper-button-prev:after,
.product-gallery-thumbs .swiper-button-next:after {
  font-size: 13px;
  font-weight: 700;
}

.product-gallery-template-3 .product-gallery-thumbs .swiper-button-prev,
.product-gallery-template-3 .product-gallery-thumbs .swiper-button-next {
  left: 50%;
  right: auto;
  transform: translateX(-50%) rotate(90deg);
}

.product-gallery-template-3 .product-gallery-thumbs .swiper-button-prev {
  top: 14px;
  margin-top: 0;
}

.product-gallery-template-3 .product-gallery-thumbs .swiper-button-next {
  top: auto;
  bottom: 14px;
  margin-top: 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 {
  margin-top: 0 !important;
  min-height: 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .swiper {
  height: auto;
  max-height: 450px;
  padding: 28px 0;
}

.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail {
  flex: 0 0 78px;
  width: 78px !important;
  height: 78px;
  margin-right: 0 !important;
  border-radius: 10px;
}

.product-gallery-template-3 .product-gallery-thumbs {
  margin-top: 0 !important;
  min-height: 0;
}

.product-gallery-template-3 .product-gallery-thumbs .swiper {
  height: auto;
  max-height: 450px;
  padding: 28px 0;
}

.product-gallery-template-3 .product-gallery-thumbs .thumb-pro-detail {
  flex: 0 0 78px;
  width: 78px !important;
  height: 78px;
  margin-right: 0 !important;
  border-radius: 10px;
}

@media (max-width: 767px) {
  .product-gallery-template-3 {
    display: block;
  }

  .product-gallery-template-3 .product-gallery-main {
    padding: 10px;
    border-radius: 12px;
  }

  .product-gallery-template-3 .product-gallery-thumbs {
    margin-top: 12px !important;
  }

  .product-gallery-template-3 .product-gallery-thumbs .swiper {
    height: auto;
    max-height: none;
    padding: 0 28px;
  }

  .product-gallery-template-3 .product-gallery-thumbs .swiper-wrapper {
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    transform: none;
  }

  .product-gallery-template-2 {
    display: block;
  }

  .product-gallery-template-2 .product-gallery-main {
    padding: 10px;
    border-radius: 12px;
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 {
    margin-top: 12px !important;
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper {
    height: auto;
    max-height: none;
    padding: 0 28px;
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper-wrapper {
    flex-direction: row;
    align-items: stretch;
    gap: 0;
  }

  .product-gallery-template-1 .album-product .thumb-pro-detail,
  .product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail,
  .product-gallery-thumbs .thumb-pro-detail {
    flex-basis: 68px;
    width: 68px !important;
    height: 68px;
  }

  .product-gallery-template-4 .product-gallery-frame {
    padding: 10px;
    border-width: 3px;
  }

  .product-gallery-template-1 .album-product .swiper,
  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper,
  .product-gallery-thumbs .swiper,
  .product-gallery-thumbs-compact .swiper {
    padding: 0 28px;
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev,
  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-prev {
    left: 4px;
  }

  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper-button-next {
    right: 4px;
    left: auto;
  }

  .product-gallery-template-3 .product-gallery-thumbs .swiper-button-prev,
  .product-gallery-template-3 .product-gallery-thumbs .swiper-button-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }

  .product-gallery-template-3 .product-gallery-thumbs .swiper-button-prev {
    left: 4px;
  }

  .product-gallery-template-3 .product-gallery-thumbs .swiper-button-next {
    right: 4px;
    left: auto;
  }
}

/* =========================================================
   PRODUCT DETAIL GALLERY - FIX MAGICZOOM
   Khung cố định + giữ hover zoom hoạt động
   ========================================================= */

.product-gallery-template {
  position: relative;
  width: 100%;
  min-width: 0;
}

/* =========================================================
   ẢNH CHÍNH
   ========================================================= */

.product-gallery-main,
.product-gallery-frame {
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 500px;
  min-height: 500px;

  padding: 20px;

  border: 1px solid #e8e8e8;
  border-radius: 6px;

  background: #fff;

  /*
   * QUAN TRỌNG:
   * không hidden vì sẽ cắt cửa sổ zoom của MagicZoom
   */
  overflow: visible !important;
}

/* =========================================================
   MAGICZOOM
   Không ép flex / height 100%
   ========================================================= */

.product-gallery-main > .MagicZoom,
.product-gallery-frame > .MagicZoom {
  display: inline-block !important;

  width: auto !important;
  height: auto !important;

  max-width: 100% !important;
  max-height: 100% !important;

  flex: 0 1 auto;

  margin: auto !important;

  line-height: 0 !important;

  background: transparent !important;
  border: 0 !important;
}

/*
 * Cho MagicZoom tự quản lý figure.
 * Không dùng width:100% + height:100% ở đây.
 */
.product-gallery-main .mz-figure,
.product-gallery-frame .mz-figure {
  display: inline-block !important;

  width: auto !important;
  height: auto !important;

  max-width: 100% !important;
  max-height: 100% !important;

  margin: 0 !important;

  /*
   * Đây là overflow của chính vùng zoom,
   * MagicZoom cần nó.
   */
  overflow: hidden !important;
}

/* =========================================================
   ẢNH PREVIEW
   ========================================================= */

.product-gallery-main .MagicZoom > img,
.product-gallery-main .mz-figure > img,
.product-gallery-frame .MagicZoom > img,
.product-gallery-frame .mz-figure > img {
  display: block !important;

  width: auto !important;
  height: auto !important;

  max-width: 100% !important;
  max-height: 455px !important;

  margin: auto !important;

  object-fit: contain !important;
  object-position: center !important;
}

/* Khi MagicZoom active không được CSS ngoài phá hiệu ứng */
.product-gallery-main .mz-figure.mz-active,
.product-gallery-frame .mz-figure.mz-active {
  overflow: hidden !important;
}

/* Cho cửa sổ zoom nổi trên layout */
.product-gallery-template .mz-zoom-window,
.product-gallery-template .mz-lens,
.product-gallery-template .mz-hint {
  z-index: 9999 !important;
}

/* =========================================================
   THUMBNAIL
   ========================================================= */

.product-gallery-template-1 .album-product,
.product-gallery-template-2 .product-gallery-thumbs-2,
.product-gallery-template-3 .product-gallery-thumbs,
.product-gallery-thumbs {
  position: relative;

  width: 100%;
  min-height: 72px;

  margin-top: 12px !important;
}

.product-gallery-template-1 .album-product .swiper,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper,
.product-gallery-template-3 .product-gallery-thumbs .swiper,
.product-gallery-thumbs .swiper {
  position: relative;

  width: 100%;
  height: auto !important;

  padding: 0 36px;

  overflow: hidden;
}

/*
 * QUAN TRỌNG:
 * KHÔNG set transform:none cho swiper-wrapper.
 * Swiper tự gắn transform inline để slide.
 */
.product-gallery-template-1 .album-product .swiper-wrapper,
.product-gallery-template-2 .product-gallery-thumbs-2 .swiper-wrapper,
.product-gallery-template-3 .product-gallery-thumbs .swiper-wrapper,
.product-gallery-thumbs .swiper-wrapper {
  flex-direction: row !important;
  align-items: stretch !important;
}

/* Thumbnail */
.product-gallery-template-1 .album-product .thumb-pro-detail,
.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail,
.product-gallery-template-3 .product-gallery-thumbs .thumb-pro-detail,
.product-gallery-thumbs .thumb-pro-detail {
  display: flex !important;

  align-items: center;
  justify-content: center;

  flex: 0 0 72px !important;

  width: 72px !important;
  height: 72px !important;

  margin-right: 8px !important;
  padding: 5px;

  border: 1px solid #ddd;
  border-radius: 5px;

  overflow: hidden;

  background: #fff;

  cursor: pointer;
}

/* Thumbnail cũng không crop */
.product-gallery-template-1 .album-product .thumb-pro-detail img,
.product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail img,
.product-gallery-template-3 .product-gallery-thumbs .thumb-pro-detail img,
.product-gallery-thumbs .thumb-pro-detail img {
  display: block;

  width: 100% !important;
  height: 100% !important;

  object-fit: contain !important;
  object-position: center !important;
}

/* Thumbnail đang chọn */
.product-gallery-template .thumb-pro-detail.mz-thumb-selected {
  border-color: #fbc000;
  box-shadow: 0 0 0 1px #fbc000;
}

/* =========================================================
   TEMPLATE 2 + 3
   Đưa thumbnail xuống dưới giống template 1
   ========================================================= */

.product-gallery-template-2,
.product-gallery-template-3 {
  display: block !important;
}

.product-gallery-template-2 .product-gallery-main,
.product-gallery-template-3 .product-gallery-main {
  grid-column: auto !important;
  grid-row: auto !important;
}

.product-gallery-template-2 .product-gallery-thumbs-2,
.product-gallery-template-3 .product-gallery-thumbs {
  grid-column: auto !important;
  grid-row: auto !important;

  margin-top: 12px !important;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1025px) {
  .product-gallery-main,
  .product-gallery-frame {
    height: 430px;
    min-height: 430px;

    padding: 18px;
  }

  .product-gallery-main .MagicZoom > img,
  .product-gallery-main .mz-figure > img,
  .product-gallery-frame .MagicZoom > img,
  .product-gallery-frame .mz-figure > img {
    max-height: 392px !important;
  }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {
  .product-gallery-main,
  .product-gallery-frame {
    width: 100%;

    height: min(92vw, 390px);
    min-height: min(92vw, 390px);

    padding: 12px;
  }

  .product-gallery-main .MagicZoom > img,
  .product-gallery-main .mz-figure > img,
  .product-gallery-frame .MagicZoom > img,
  .product-gallery-frame .mz-figure > img {
    max-height: calc(min(92vw, 390px) - 24px) !important;
  }

  .product-gallery-template-1 .album-product .swiper,
  .product-gallery-template-2 .product-gallery-thumbs-2 .swiper,
  .product-gallery-template-3 .product-gallery-thumbs .swiper,
  .product-gallery-thumbs .swiper {
    padding: 0 28px;
  }

  .product-gallery-template-1 .album-product .thumb-pro-detail,
  .product-gallery-template-2 .product-gallery-thumbs-2 .thumb-pro-detail,
  .product-gallery-template-3 .product-gallery-thumbs .thumb-pro-detail,
  .product-gallery-thumbs .thumb-pro-detail {
    flex-basis: 64px !important;

    width: 64px !important;
    height: 64px !important;
  }
}
/* =========================================================
   FIX KÍCH THƯỚC ẢNH SẢN PHẨM - KHÔNG ẢNH HƯỞNG DETAIL
   ========================================================= */

.product-list-photo a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  height: 180px !important;
  padding: 15px !important;
  overflow: hidden;
}

.product-list-photo picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.product-list-photo img {
  display: block !important;

  width: auto !important;
  height: auto !important;

  max-width: 260px !important;
  max-height: 150px !important;

  object-fit: contain !important;
  object-position: center !important;

  transform: none !important;
}

/* Không zoom ảnh khi hover */
.product-list-photo .scale-img:hover > img,
.product-list-photo .scale-img:hover picture > img {
  transform: none !important;
}
/* =========================================================
   DETAIL PRODUCT - CHỈ ĐỔI KÍCH THƯỚC ẢNH
   Giữ nguyên vị trí + MagicZoom hover
   ========================================================= */

.product-detail-template
  .product-gallery-main
  > .MagicZoom
  > img,

.product-detail-template
  .product-gallery-main
  > .MagicZoom
  > .mz-figure
  > img {
  width: 350px !important;
  height: 200px !important;

  max-width: 100% !important;
  max-height: 200px !important;

  object-fit: contain !important;
  object-position: center !important;
}