.woocommerce-product-gallery__image {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.woocommerce-product-gallery__image.hlv-video-slide,
.woocommerce-product-gallery__image.yt-playing {
  background: #000;
}

.wpcpv-item-video {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: block;
  cursor: pointer;
}

.wpcpv-item-video::after {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 31;
  width: 68px;
  height: 48px;
  content: "";
  background: rgba(0, 0, 0, 0.6);
  border-radius: 14px;
  transition: background 0.2s ease;
  transform: translate(-50%, -50%);
}

.wpcpv-item-video::before {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 32;
  width: 22px;
  height: 24px;
  pointer-events: none;
  content: "";
  background: #fff;
  clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
  transform: translate(-35%, -50%);
}

.wpcpv-item-video:hover::after {
  background: #d2212e;
}

.woocommerce-product-gallery__image iframe.yt-inline {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #000;
  border: 0;
}

.hlv-youtube-facade {
	position: relative;
	width: 100%;
	max-width: 840px;
	margin: 20px auto;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: #111;
}

.hlv-youtube-facade > img,
.hlv-youtube-facade > iframe {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 0;
}

.hlv-youtube-facade__button {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	cursor: pointer;
	background: transparent;
	border: 0;
}

.hlv-youtube-facade__button span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 68px;
	height: 48px;
	background: #e00000;
	border-radius: 12px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
	transform: translate(-50%, -50%);
}

.hlv-youtube-facade__button span::after {
	position: absolute;
	top: 50%;
	left: 53%;
	width: 0;
	height: 0;
	content: "";
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
	border-left: 17px solid #fff;
	transform: translate(-50%, -50%);
}

.woocommerce-product-gallery__image.yt-playing .wpcpv-item-video {
  display: none;
}

.flex-control-thumbs li.video-thumb {
  position: relative;
}

.flex-control-thumbs li.video-thumb::after {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 26px;
  height: 26px;
  content: "";
  background: rgba(210, 33, 46, 0.9);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

.flex-control-thumbs li.video-thumb::before {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  content: "";
  border-color: transparent transparent transparent #fff;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  transform: translate(-35%, -50%);
}

.branches-wrap.open .action::after {
  display: none !important;
}

/* Payment methods are supporting information, not primary purchase actions. */
.single-product .hlv-payment-methods {
  margin: 7px 0 12px;
  color: #62676b;
  font-size: 12px;
  line-height: 1.5;
}

.single-product .hlv-payment-methods a {
  color: #1177b7;
  font-weight: 600;
  text-decoration: none;
}

.single-product .hlv-payment-methods a:hover,
.single-product .hlv-payment-methods a:focus-visible {
  color: #d2212e;
  text-decoration: underline;
}

/* Baokim still mounts its controls for the popup, but they no longer compete
 * visually with the two purchase actions. */
.single-product .card-singl-product .bk-btn,
.single-product .card-singl-product .installment-btn {
  display: none !important;
}

.hlv-mobile-purchase-bar {
  display: none;
}

/* WooCommerce appends a secondary "view cart" link beside the product CTA
 * after AJAX succeeds. The header cart is already updated, so the shortcut is
 * redundant and must not reflow the two primary purchase actions. */
.single-product .singl-product form.cart .added_to_cart.wc-forward,
.single-product .summary form.cart .added_to_cart.wc-forward,
.single-product .hlv-mobile-purchase-bar > .added_to_cart.wc-forward {
  display: none !important;
}

.single-product .singl-product form.cart .btn-cart {
  align-items: stretch;
}

.hlv-fly-to-cart {
  position: fixed;
  z-index: 10050;
  object-fit: contain;
  pointer-events: none;
  background: #fff;
  border: 2px solid #fdc400;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: hlv-fly-to-cart 0.72s cubic-bezier(0.2, 0.75, 0.25, 1) forwards;
}

@keyframes hlv-fly-to-cart {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  70% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--hlv-fly-x), var(--hlv-fly-y), 0) scale(0.18);
  }
}

.icon-cart.hlv-cart-receiving,
header .icon-cart.hlv-cart-receiving {
  animation: hlv-cart-receiving 0.5s ease both;
}

@keyframes hlv-cart-receiving {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.24) rotate(-7deg);
  }
}

/* Let Swiper stretch every related-product card to the tallest item. The old
 * inline fixed height was calculated before Swiper resized mobile slides and
 * clipped titles/prices when three narrow cards were shown. */
.single-product .related-swiper .swiper-wrapper {
  align-items: stretch;
}

.single-product .related-swiper .swiper-slide {
  height: auto;
}

.single-product .related-swiper .product-item {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.single-product .related-swiper .product-item .detail {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  height: auto !important;
}

.single-product .related-swiper .product-item .price-wrap {
  margin-top: auto;
}

@media (max-width: 768px) {
  :root {
    --hlv-mobile-purchase-height: 64px;
    --hlv-mobile-purchase-safe-area: env(safe-area-inset-bottom, 0px);
  }

  .hlv-has-mobile-purchase-bar .fixed-bottom-toolbar {
    display: none !important;
  }

  /* Keep the original controls in the form for WooCommerce/third-party hooks,
   * but do not show a duplicate action row beside the native sticky submits. */
  .hlv-has-mobile-purchase-bar .singl-product form.cart .btn-cart {
    display: none !important;
  }

  .single-product .hlv-payment-methods {
    order: -1;
  }

  .hlv-has-mobile-purchase-bar .site-footer {
    margin-bottom: calc(
      var(--hlv-mobile-purchase-height) + var(--hlv-mobile-purchase-safe-area)
    );
  }

  .hlv-has-mobile-purchase-bar .fixed-contact {
    right: 12px;
    bottom: calc(
      var(--hlv-mobile-purchase-height) + var(--hlv-mobile-purchase-safe-area) + 12px
    );
    z-index: 999;
    transform: none;
  }

  .hlv-has-mobile-purchase-bar .fixed-contact img {
    width: 46px;
    height: 46px;
  }

  .single-product .singl-product-slider .flex-viewport,
  .single-product .singl-product-slider .woocommerce-product-gallery__wrapper,
  .single-product .singl-product-slider .woocommerce-product-gallery__image {
    height: clamp(300px, 42vh, 380px) !important;
    min-height: 0 !important;
    background-color: #fff;
  }

  .single-product .singl-product-slider .woocommerce-product-gallery__image img {
    width: 100% !important;
    height: 100% !important;
    max-height: clamp(300px, 42vh, 380px) !important;
    aspect-ratio: auto;
    object-fit: contain;
  }

  .single-product .singl-product-slider .woocommerce-product-gallery__image.hlv-video-slide,
  .single-product .singl-product-slider .woocommerce-product-gallery__image.yt-playing {
    background-color: #000;
  }

  .single-product .singl-product-slider .woocommerce-product-gallery.hlv-gallery-no-thumbs {
    margin-bottom: 15px !important;
  }

  .hlv-mobile-purchase-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    box-sizing: border-box;
    width: auto;
    max-width: none;
    height: calc(
      var(--hlv-mobile-purchase-height) + var(--hlv-mobile-purchase-safe-area)
    );
    padding: 0 0 var(--hlv-mobile-purchase-safe-area);
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.14);
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.14);
  }

  .hlv-mobile-purchase-bar > button,
  .hlv-mobile-purchase-bar > a {
    display: flex;
    flex: 0 0 50%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 50%;
    max-width: none;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 7px 5px;
    color: #fff;
    font: inherit;
    line-height: 1.15;
    text-align: center;
    border: 0;
    border-radius: 0;
    touch-action: manipulation;
    text-decoration: none;
  }

  .hlv-mobile-purchase-bar > button:focus-visible,
  .hlv-mobile-purchase-bar > a:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid #fff;
    outline-offset: -5px;
  }

  .hlv-mobile-add-to-cart {
    color: #084f7d !important;
    background: #fdc400;
  }

  .hlv-mobile-buy-now {
    color: #fff !important;
    background: #1177b7;
    border-left: 1px solid rgba(255, 255, 255, 0.35) !important;
  }

  .hlv-mobile-add-to-cart:focus-visible {
    outline-color: #084f7d;
  }

  .single-product .related-swiper .product-item .detail {
    padding: 10px 10px 16px;
  }

  .single-product .related-swiper .product-item .detail .price-wrap .percent-sale {
    margin-left: 8px;
  }

  .single-product .singl-product-related .owl-w-nav .owl-nav .owl-prev {
    left: 0;
  }

  .single-product .singl-product-related .owl-w-nav .owl-nav .owl-next {
    right: 0;
  }

  .hlv-mobile-purchase-bar > button > span,
  .hlv-mobile-purchase-bar > a > span {
    font-size: 13px;
    font-weight: 800;
  }

  .hlv-mobile-purchase-price {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 700;
  }

  .hlv-mobile-purchase-bar > button:disabled,
  .hlv-mobile-purchase-bar > button.is-disabled {
    cursor: not-allowed;
    filter: grayscale(0.3);
    opacity: 0.58;
  }

  .hlv-mobile-purchase-bar > button.is-loading::after {
    width: 16px;
    height: 16px;
    margin-top: 3px;
    content: "";
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: hlv-cart-spinner 0.65s linear infinite;
  }

  .hlv-mobile-purchase-bar > button.is-loading > span,
  .hlv-mobile-purchase-bar > button.is-loading > strong {
    display: none;
  }

  @keyframes hlv-cart-spinner {
    to {
      transform: rotate(360deg);
    }
  }

}
