/* =========================================
   Product Loop Card (SuntechMall-VPro) — FINAL (clean + stable)
   Location: /assets/css/product-loop.css
   Purpose:
   - Shop, home, wishlist, and single-product recommendation loop card UI.
   - Keeps hover actions scoped to the feature image area.
   - Keeps recommendation cards stable in their own grid without stretching.
   - Normalizes Quick View + Compare overlay button positions.
   - Keeps title, price/rating and action rows in normal document flow for guest + logged-in users.
========================================= */

/* Keep Woo list clean */
.woocommerce ul.products,
.woocommerce ul.products li.product{
  overflow: visible !important; /* allow shadow */
}

.woocommerce ul.products{
  gap: 2px !important; /* your requirement */
}

/* Ensure hover can come above neighbors */
.woocommerce ul.products li.product{
  position: relative;
  z-index: 1;
}
.woocommerce ul.products li.product:hover{
  z-index: 20;
}

/* Single product recommendation rows: keep hovered card/action buttons above neighbors */
.single-product .stm-sp__below,
.single-product .up-sells.upsells,
.single-product .related.products,
.single-product .up-sells.upsells ul.products,
.single-product .related.products ul.products{
  overflow: visible !important;
}

.single-product .up-sells.upsells ul.products > li.product,
.single-product .related.products ul.products > li.product{
  position: relative;
  z-index: 1;
}

.single-product .up-sells.upsells ul.products > li.product:hover,
.single-product .related.products ul.products > li.product:hover{
  z-index: 50;
}

/* If your theme uses .stm-product-card wrapper, keep it harmless */
.stm-product-card{
  list-style: none;
  border: none !important;
  border-radius: 0 !important;
}

/* Card shell */
.stm-pl{
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: visible;

  padding: 6px 15px 10px;
  background: #fff;
  border: none !important;
  border-radius: 0 !important;

  /* Hover shadow anchor */
  transition: box-shadow .18s ease, transform .18s ease;
}

/* Hover shadow (single source of truth) */
.woocommerce ul.products li.product:hover .stm-pl{
  box-shadow: 0 0px 6px rgba(0,0,0,.25);
}

/* Category */
.stm-pl__cat{
  font-size: 14px;
  text-transform: uppercase;
  color: rgba(0,0,0,.65);
  text-decoration: none;
}
.stm-pl__cat:hover{
  color: rgba(0,0,0,.92);
  text-decoration: underline;
}

/* Feature image */
.stm-pl__media{
  position: relative; /* for Quick View + Compare overlay */
  isolation: isolate;
  z-index: 1;
  padding: 0;
  border-radius: 10px;
  background: #fff;
  border: none !important;
  overflow: hidden;
}
.stm-pl__media img{
  width: 100%;
  height: auto;
  display: block;
}

/* Title + spacing
   FIX:
   - No negative translateY.
   - Title keeps its own 2-line space.
   - Price/rating row stays below title and cannot cover it.
   - Same layout applies for logged-in and guest users.
   - Content block is pulled 10px upward using safe margin, not transform.
   - Product title is visually nudged 5px upward without moving price/rating/action rows.
*/
.stm-pl__link{
  position: relative;
  z-index: 2;
  display: block;
  color: inherit;
  text-decoration: none;
  overflow: visible !important;
}

.woocommerce ul.products li.product .stm-pl .stm-pl__title,
.stm-pl__title{
  position: relative;
  z-index: 4;

  margin: -4px 0 6px !important;
  padding: 0 !important;
  transform: none !important;
  top: -5px !important;

  background: transparent !important;
  color: #0e5aa7;

  font-size: 16px !important;
  line-height: 1.35 !important;
  font-weight: 700 !important;

  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  min-height: calc(1.35em * 2);
  max-height: calc(1.35em * 2);
  overflow: hidden !important;
  word-break: normal;
  overflow-wrap: anywhere;
}

.stm-pl__link:hover .stm-pl__title{
  color: #0b3a6f;
  text-decoration: underline;
}

/* Rows */
.stm-pl__row{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  background: transparent !important;
}

/* Price */
.stm-pl__price,
.stm-pl__price .amount{
  font-size: 16px !important;
  font-weight: 400 !important;
  color: #000 !important;
}
.stm-pl__price del{ opacity:.55; }
.stm-pl__price ins{ text-decoration:none; }

.stm-pl__price,
.stm-pl__rating,
.stm-stars{
  position: relative;
  z-index: 1;
  background: transparent !important;
}

/* Stars */
.stm-stars{
  position: relative;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 1px;
}
.stm-stars__base{ color: rgba(0,0,0,.22); }
.stm-stars__fill{
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #f5a623;
}

/* Meta + actions rows
   FIX: keep both rows in normal flow. Negative transforms made guest product titles hide/cut.
*/
.woocommerce ul.products li.product .stm-pl .stm-pl__row--meta,
.stm-pl__row--meta{
  z-index: 1;
  margin: 0 0 4px !important;
  padding: 0 !important;
  transform: none !important;
  background: transparent !important;
}

.woocommerce ul.products li.product .stm-pl .stm-pl__row--actions,
.stm-pl__row--actions{
  z-index: 3;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  background: transparent !important;
}

/* =========================
   Wishlist fallback link (only if hook outputs nothing)
   FIX: correct icon path => ../icons/ (NOT ../css/icons/)
========================= */
.stm-pl__wish{
  width: 38px;
  height: 38px;
  border: none !important;
  background: transparent !important;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  padding: 0;
}
.stm-pl__icon--wish{
  width: 28px;
  height: 28px;
  display:block;
  background: url("../icons/wishlist.svg") center/28px 28px no-repeat;
}

/* =========================
   Add to cart (icon button)
========================= */
.stm-pl__atc{
  width: 36px;
  height: 36px;
  border-radius: 999px !important;
  background: #ff7a00 !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  text-decoration: none !important;
  border: none !important;
  padding: 0 !important;

  line-height: 0 !important;
  font-size: 0 !important;
  vertical-align: middle;
}

.stm-pl__icon--atc{
  width: 18px;
  height: 18px;
  display: block;

  background: url("../icons/add-to-cart.svg") center center / 18px 18px no-repeat;

  filter: brightness(0) invert(1);
  margin: 0 !important;
  padding: 0 !important;
}

.stm-pl__atc.is-added .stm-pl__icon--atc{
  background-image: url("../icons/tick.svg");
}

/* ======================================================
   WISHLIST ICON — SINGLE SVG + CSS MASK (PREMIUM)
   Uses: assets/icons/wishlist.svg
====================================================== */
.stm-pl-action--wishlist{
  position: relative;
  width: 38px;
  height: 38px;
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0;
  cursor: pointer;

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

  -webkit-tap-highlight-color: transparent;
}

.stm-pl-action--wishlist::before{
  content: "" !important;
  width: 20px;
  height: 20px;
  display: block;

  background-image: var(--stm-wish-ico) !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;

  -webkit-mask: none !important;
  mask: none !important;
  background-color: transparent !important;
}

.stm-pl-action--wishlist.is-added::before{
  background-image: none !important;
  background-color: #000 !important;

  -webkit-mask-image: var(--stm-wish-ico) !important;
  mask-image: var(--stm-wish-ico) !important;

  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;

  -webkit-mask-position: center !important;
  mask-position: center !important;

  -webkit-mask-size: contain !important;
  mask-size: contain !important;
}

.stm-pl-action--wishlist:hover{ opacity: 0.9; }

.stm-pl-action--wishlist.is-loading{
  pointer-events: none;
  opacity: 0.6;
}

.stm-pl-action--wishlist:focus-visible{
  outline: 2px solid rgba(0,0,0,.25);
  outline-offset: 2px;
}

/* =========================================
   Wishlist Page — Force 6 columns
========================================= */
.stm-wishlist-page ul.products{
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 1200px){
  .stm-wishlist-page ul.products{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px){
  .stm-wishlist-page ul.products{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px){
  .stm-wishlist-page ul.products{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================
   QUICK VIEW — overlay button in media center (desktop image-hover only)
   Same geometry is repeated in Quick View CSS so single product loops stay identical.
========================================= */
.stm-pl__media .stm-qv-btn,
.stm-pl__media .stm-qv-trigger{
  position:absolute;
  left:50%;
  top:calc(50% - 22px);
  transform:translate(-50%,-50%) scale(.98);
  z-index:8;

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

  min-width:96px;
  height:36px;
  padding:0 16px;

  font-weight:800;
  font-size:12px;
  line-height:1;
  white-space:nowrap;
  border-radius:999px;

  border:1px solid #ff7a00;
  background:#ff7a00;
  color:#fff;

  opacity:0;
  pointer-events:none;
  transition:opacity .16s ease, transform .16s ease, background-color .16s ease, border-color .16s ease;
}

@media (hover:hover) and (pointer:fine){
  .stm-pl__media .stm-qv-btn:hover,
  .stm-pl__media .stm-qv-btn:focus-visible,
  .stm-pl__media .stm-qv-trigger:hover,
  .stm-pl__media .stm-qv-trigger:focus-visible{
    background:#e65f00;
    border-color:#e65f00;
    color:#fff;
  }

  .stm-pl__media .stm-qv-btn:active,
  .stm-pl__media .stm-qv-trigger:active{
    transform:translate(-50%,-50%) scale(.98);
  }

  .stm-pl__media:hover .stm-qv-btn,
  .stm-pl__media:hover .stm-qv-trigger{
    opacity:1;
    pointer-events:auto;
    transform:translate(-50%,-50%) scale(1);
  }
}

/* touch devices => hide */
@media (hover:none){
  .stm-pl__media .stm-qv-btn,
  .stm-pl__media .stm-qv-trigger{ display:none !important; }
}


/* =========================================
   Guest/Login Consistency Guard
   Purpose: force identical product-loop layering for cached guest HTML and logged-in HTML.
========================================= */
body.logged-in .woocommerce ul.products li.product .stm-pl,
body:not(.logged-in) .woocommerce ul.products li.product .stm-pl{
  padding-bottom: 10px !important;
}

body.logged-in .woocommerce ul.products li.product .stm-pl__title,
body:not(.logged-in) .woocommerce ul.products li.product .stm-pl__title{
  transform: none !important;
  margin-top: -4px !important;
  top: -5px !important;
  position: relative !important;
  z-index: 4 !important;
}

body.logged-in .woocommerce ul.products li.product .stm-pl__row--meta,
body:not(.logged-in) .woocommerce ul.products li.product .stm-pl__row--meta,
body.logged-in .woocommerce ul.products li.product .stm-pl__row--actions,
body:not(.logged-in) .woocommerce ul.products li.product .stm-pl__row--actions{
  transform: none !important;
  background: transparent !important;
}


/* ======================================================
   Premium sale badge for product cards
====================================================== */
.woocommerce ul.products li.product .stm-pl__media span.onsale.stm-sale-badge,
.woocommerce ul.products li.product span.onsale.stm-sale-badge{
  position:absolute;
  top:8px;
  left:8px;
  z-index:12;
  min-width:0;
  min-height:0;
  width:auto;
  height:auto;
  margin:0;
  padding:6px 9px;
  border:1px solid rgba(255,255,255,.7);
  border-radius:999px;
  background:linear-gradient(135deg,#dc2626 0%,#f97316 100%);
  color:#fff;
  box-shadow:0 7px 16px rgba(220,38,38,.22);
  font-size:10px;
  font-weight:900;
  line-height:1;
  letter-spacing:.02em;
  text-transform:uppercase;
}
.woocommerce ul.products li.product .stm-pl__media span.onsale.stm-sale-badge span{display:block;}
