/* TVS Product Card: shared storefront component for Woo template loops and Elementor loop items. */

.tvs-product-card {
  --tvs-card-title-zone: calc(4.35em + 24px);
  --tvs-card-price-zone: calc(3.4em + 16px);
}

ul.products > li.tvs-product-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto var(--tvs-card-title-zone) var(--tvs-card-price-zone);
  align-content: start;
  height: 100%;
  min-width: 0;
  position: relative;
  float: none !important;
  clear: none !important;
  width: auto !important;
  max-width: none !important;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--tvs-border);
  border-radius: var(--tvs-radius-md);
  background: var(--tvs-surface);
  box-shadow: 0 1px 2px rgb(17 19 22 / 0.04);
}

ul.products > li.tvs-product-card .tvs-product-card__media {
  grid-row: 1;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  padding: 12px;
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--tvs-commerce-surface);
}

ul.products > li.tvs-product-card .tvs-product-card__media > .woocommerce-LoopProduct-link {
  display: block;
  width: 100%;
  height: 100%;
}

ul.products > li.tvs-product-card .tvs-product-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center;
}

ul.products > li.tvs-product-card .tvs-product-card__title-link {
  grid-row: 2;
  display: block;
  width: 100%;
  height: var(--tvs-card-title-zone);
  min-width: 0;
  padding: 16px 16px 8px;
  color: var(--tvs-text);
  text-decoration: none;
  box-sizing: border-box;
}

ul.products > li.tvs-product-card .woocommerce-loop-product__title {
  display: -webkit-box;
  height: 4.35em;
  margin: 0;
  overflow: hidden;
  color: var(--tvs-text);
  font-family: var(--tvs-font-sans);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

ul.products > li.tvs-product-card .price {
  grid-row: 3;
  display: flex;
  width: 100%;
  height: var(--tvs-card-price-zone);
  margin: 0;
  padding: 0 16px 16px;
  align-content: flex-start;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  overflow: hidden;
  color: var(--tvs-price);
  font-size: 1.125rem;
  font-weight: 700;
  box-sizing: border-box;
}

.tvs-product-card .price del {
  color: var(--tvs-muted);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 1;
}

.tvs-product-card .price ins {
  color: var(--tvs-price-sale);
  text-decoration: none;
}

ul.products > li.tvs-product-card > .button {
  display: none !important;
}

.tvs-product-card .br_wish_wait_block,
.tvs-product-card .tvs-product-card__elementor-wishlist {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  width: auto;
  margin: 0;
}

.tvs-product-card .br_wish_button,
.tvs-product-card .tvs-product-card__elementor-wishlist .br_wish_button {
  display: inline-flex;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--tvs-border);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.94);
  box-shadow: 0 1px 4px rgb(17 19 22 / 0.12);
  color: var(--tvs-muted);
}

.tvs-product-card .onsale,
.tvs-product-card .tvs-product-card__sale {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--tvs-radius-sm);
  background: var(--tvs-sale);
  color: var(--tvs-text);
  font-family: var(--tvs-font-sans);
  font-size: var(--tvs-font-size-xs);
  font-weight: 700;
  line-height: 1;
}

.tvs-product-card .tvs-product-card__media::after,
.tvs-product-card .tvs-product-card__elementor-media::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: rgb(17 19 22 / 0.52);
  content: '';
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.tvs-product-card .tvs-product-card__quick-action,
.tvs-product-card .tvs-product-card__elementor-quick-action {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  align-items: center;
  justify-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.tvs-product-card :is(.tvs-product-card__quick-action, .tvs-product-card__elementor-quick-action) .button {
  display: inline-flex;
  width: auto;
  min-height: var(--tvs-control-height);
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid var(--tvs-orange);
  border-radius: var(--tvs-radius-sm);
  background: var(--tvs-orange);
  color: var(--tvs-text);
  font-family: var(--tvs-font-sans);
  font-size: var(--tvs-font-size-sm);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

/* Elementor Loop Grid/Carousel adapter: same product class, different widget slots. */
.elementor-loop-container .e-loop-item.product.tvs-product-card {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--tvs-border);
  border-radius: var(--tvs-radius-md);
  background: var(--tvs-surface);
  box-shadow: 0 1px 2px rgb(17 19 22 / 0.04);
}

.elementor-loop-container .e-loop-item.product.tvs-product-card > .e-con,
.elementor-loop-container .e-loop-item.product.tvs-product-card > .e-con > .e-con-inner {
  min-height: 100%;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card > .e-con > .e-con-inner {
  display: grid;
  grid-template-rows: auto var(--tvs-card-title-zone) var(--tvs-card-price-zone);
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .tvs-product-card__elementor-media {
  grid-row: 1;
  min-width: 0;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  padding: 12px;
  position: relative;
  overflow: hidden;
  background: var(--tvs-commerce-surface);
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .tvs-product-card__elementor-media :is(a, img) {
  display: block;
  width: 100%;
  height: 100%;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .tvs-product-card__elementor-media img {
  object-fit: contain;
  object-position: center;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-title {
  grid-row: 2;
  height: var(--tvs-card-title-zone);
  min-width: 0;
  padding: 16px 16px 8px;
  box-sizing: border-box;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-title :is(h1, h2, h3, h4, h5, h6, .elementor-heading-title) {
  display: -webkit-box;
  height: 4.35em;
  margin: 0;
  overflow: hidden;
  color: var(--tvs-text);
  font-family: var(--tvs-font-sans);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-price {
  grid-row: 3;
  height: var(--tvs-card-price-zone);
  padding: 0 16px 16px;
  box-sizing: border-box;
}

.elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-price .price {
  display: flex;
  margin: 0;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--tvs-price);
  font-size: 1.125rem;
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .tvs-product-card:hover :is(.tvs-product-card__media, .tvs-product-card__elementor-media)::after,
  .tvs-product-card :is(.tvs-product-card__media, .tvs-product-card__elementor-media):focus-within::after,
  .tvs-product-card:hover :is(.tvs-product-card__quick-action, .tvs-product-card__elementor-quick-action),
  .tvs-product-card :is(.tvs-product-card__media, .tvs-product-card__elementor-media):focus-within :is(.tvs-product-card__quick-action, .tvs-product-card__elementor-quick-action) {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 767px) {
  .tvs-product-card {
    --tvs-card-title-zone: calc(4.35em + 18px);
    --tvs-card-price-zone: calc(3.4em + 12px);
  }

  ul.products > li.tvs-product-card .tvs-product-card__media,
  .elementor-loop-container .e-loop-item.product.tvs-product-card .tvs-product-card__elementor-media {
    padding: 8px;
  }

  ul.products > li.tvs-product-card .tvs-product-card__title-link,
  .elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-title {
    padding: 12px 12px 6px;
  }

  ul.products > li.tvs-product-card .price,
  .elementor-loop-container .e-loop-item.product.tvs-product-card .elementor-widget-woocommerce-product-price {
    padding: 0 12px 12px;
    font-size: 1rem;
  }

  .tvs-product-card .br_wish_wait_block,
  .tvs-product-card .tvs-product-card__elementor-wishlist { top: 8px; right: 8px; }
  .tvs-product-card .br_wish_button,
  .tvs-product-card .tvs-product-card__elementor-wishlist .br_wish_button { width: 34px; min-width: 34px; height: 34px; min-height: 34px; }
  .tvs-product-card .onsale,
  .tvs-product-card .tvs-product-card__sale { top: 8px; left: 8px; }
  .tvs-product-card :is(.tvs-product-card__quick-action, .tvs-product-card__elementor-quick-action) { display: none; }
}

/* Elementor Products widgets set per-widget type rules; keep their cards on the shared price scale. */
body .elementor-wc-products ul.products > li.tvs-product-card .price {
  color: var(--tvs-price);
  font-size: 1.125rem;
  font-weight: 700;
}

body .elementor-wc-products ul.products > li.tvs-product-card .price del {
  color: var(--tvs-muted);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 1;
}

body .elementor-wc-products ul.products > li.tvs-product-card .price ins {
  color: var(--tvs-price-sale);
  text-decoration: none;
}

@media (max-width: 767px) {
  body .elementor-wc-products ul.products > li.tvs-product-card .price {
    font-size: 1rem;
  }
}

/* Elementor page CSS targets widget buttons and sale badges with per-page selectors. */
body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card .br_wish_wait_block span.br_wish_button {
  display: inline-flex;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--tvs-border);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.94);
  box-shadow: 0 1px 4px rgb(17 19 22 / 0.12);
  color: var(--tvs-muted);
}

body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card span.onsale {
  display: inline-flex;
  width: auto;
  max-width: calc(100% - 20px);
  top: 10px;
  right: auto;
  left: 10px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--tvs-radius-sm);
  background: var(--tvs-sale);
  color: var(--tvs-text);
  font-family: var(--tvs-font-sans);
  font-size: var(--tvs-font-size-xs);
  font-weight: 700;
  line-height: 1;
}

/*
 * Elementor Products widgets emit page-specific button rules. This selector is
 * renderer-bound rather than page-bound, so every Elementor Woo loop keeps the
 * same quick-action CTA without touching its persistent product links.
 */
body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__quick-action > .button,
body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__elementor-quick-action > .button {
  border-color: var(--tvs-orange);
  border-radius: var(--tvs-radius-sm);
  background-color: var(--tvs-orange);
  color: var(--tvs-text);
}

body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__quick-action > .button:hover,
body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__quick-action > .button:focus-visible,
body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__elementor-quick-action > .button:hover,
body .elementor.elementor .elementor-wc-products.elementor-widget ul.products > li.product.tvs-product-card .tvs-product-card__elementor-quick-action > .button:focus-visible {
  border-color: color-mix(in srgb, var(--tvs-orange), var(--tvs-near-black) 16%);
  background-color: color-mix(in srgb, var(--tvs-orange), var(--tvs-near-black) 16%);
  color: var(--tvs-text);
}

@media (max-width: 767px) {
  body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card .br_wish_wait_block { top: 8px; right: 8px; }
  body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card .br_wish_wait_block span.br_wish_button { width: 34px; min-width: 34px; height: 34px; min-height: 34px; }
  body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card span.onsale { top: 8px; left: 8px; }
}

/*
 * Bridge 1.3.5: one grid contract for every native WooCommerce loop.
 * The component class, rather than a route or Elementor page id, is the
 * selector boundary. This wins over the older archive columns-3 fallback.
 */
ul.products:has(> li.tvs-product-card) {
  display: grid;
  gap: 24px;
  margin: 0;
  padding: 0;
}

ul.products:has(> li.tvs-product-card)::before,
ul.products:has(> li.tvs-product-card)::after {
  display: none;
}

ul.products:has(> li.tvs-product-card) > li.tvs-product-card {
  float: none !important;
  clear: none !important;
  width: auto !important;
  max-width: none !important;
  justify-self: stretch;
}

/* The deliberately scoped override neutralizes an older, more-specific loop overlay. */
.tvs-product-card :is(.tvs-product-card__media, .tvs-product-card__elementor-media)::after {
  background: rgb(0 0 0 / 0.34) !important;
}

/* WooCommerce's legacy highlight colour must not escape the shared TVS sale token. */
body.woocommerce .tvs-product-card span.onsale,
body.woocommerce-page .tvs-product-card span.onsale,
.tvs-product-card .tvs-product-card__sale {
  display: inline-flex;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  background-color: var(--tvs-sale);
  text-align: center;
}

/*
 * One sale-badge geometry contract for every TVS Product Card renderer.
 * Elementor loops and native related/upsell loops previously supplied more
 * specific legacy badge dimensions and corner radii. These component-bound
 * selectors intentionally win without introducing route-specific styling.
 */
body.woocommerce .tvs-product-card span.onsale,
body.woocommerce-page .tvs-product-card span.onsale,
body .elementor-wc-products ul.products.products[class*="columns-"] > li.product.tvs-product-card span.onsale,
.single-product .site-main :is(.related.products, .upsells.products) ul.products li.product.tvs-product-card span.onsale,
.tvs-product-card .tvs-product-card__sale {
  display: inline-flex;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  background-color: var(--tvs-sale);
  text-align: center;
}

@media (min-width: 1200px) {
  ul.products:has(> li.tvs-product-card) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  ul.products:has(> li.tvs-product-card) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  ul.products:has(> li.tvs-product-card) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}
