/* TONGIA Media Sync — ảnh sản phẩm đồng bộ, không sửa ảnh gốc. */
.tgms-frame {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: var(--tgms-frame-ratio, 1/1);
  overflow: hidden !important;
  background: #fff;
  isolation: isolate;
}

.tgms-frame > .tgms-image-holder,
.tgms-frame .tgms-image-holder {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

.tgms-frame img.tgms-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: var(--tgms-fit, contain) !important;
  object-position: var(--tgms-object-position, 50% 50%) !important;
  background: #fff;
}

.tgms-frame::after {
  content: "";
  position: absolute;
  z-index: 20;
  top: var(--tgms-logo-inset, 3%);
  left: var(--tgms-logo-inset, 3%);
  width: min(var(--tgms-logo-width, 14%), var(--tgms-logo-max, 66px));
  aspect-ratio: 1/1;
  pointer-events: none;
  background-color: rgba(255, 255, 255, 0.94);
  background-image: var(--tgms-logo-image);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 78% auto;
  border: 1px solid rgba(0, 65, 115, 0.12);
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(15, 40, 65, 0.16);
}

/* Ảnh chính và gallery WooCommerce / Flatsome. */
.woocommerce-product-gallery__image.tgms-frame > a,
.woocommerce-product-gallery__image.tgms-frame > div {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}

/* Card shop, danh mục, tìm kiếm, slider và sản phẩm tương tự. */
.product-small .box-image.tgms-frame,
.product-category .box-image.tgms-frame,
.products .product .box-image.tgms-frame,
.search-results .product .box-image.tgms-frame {
  min-height: 0 !important;
}

.product-small .box-image.tgms-frame .image-none,
.product-small .box-image.tgms-frame a,
.product-category .box-image.tgms-frame a,
.products .product .box-image.tgms-frame a,
.search-results .product .box-image.tgms-frame a {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
}

/* Thumbnail nhỏ giữ logo gọn để không che sản phẩm. */
.tgms-thumb-frame::after {
  border-radius: 6px;
  background-size: 75% auto;
}

/* Ngoại lệ bắt buộc: không crop và không phủ logo lên banner, bài viết hoặc video. */
.ux-banner .tgms-frame,
.banner .tgms-frame,
.video .tgms-frame,
video .tgms-frame,
.post-item .tgms-frame,
.blog-post-inner .tgms-frame {
  aspect-ratio: auto !important;
  overflow: visible !important;
}

.ux-banner .tgms-frame::after,
.banner .tgms-frame::after,
.video .tgms-frame::after,
video .tgms-frame::after,
.post-item .tgms-frame::after,
.blog-post-inner .tgms-frame::after {
  display: none !important;
}

@media (max-width: 849px) {
  .tgms-frame::after {
    width: min(var(--tgms-logo-width, 14%), 52px);
    border-radius: 7px;
  }
}

@media (max-width: 549px) {
  .tgms-frame::after {
    width: min(var(--tgms-logo-width, 14%), 44px);
    box-shadow: 0 1px 5px rgba(15, 40, 65, 0.14);
  }
}
