/* ==========================================================================
   Ecolux — WooCommerce loop product card
   Applies to the shop archive, brand archives and product category archives
   (markup: ul.product-box > li.product > .product-box-inner > .info-product)

   Pure CSS, no JS, no external assets. Loaded after the theme stylesheets so
   plain selectors win; !important is only used where the theme uses it too.
   ========================================================================== */

:root {
  --ecx-ink:        #191b1f;
  --ecx-ink-2:      #5b6270;
  --ecx-ink-3:      #8b91a0;
  --ecx-line:       #ececf1;
  --ecx-line-soft:  #f3f4f7;
  --ecx-surface:    #ffffff;
  --ecx-sale:       #e11d48;
  --ecx-sale-soft:  #fff1f4;
  --ecx-ok:         #15a34a;
  --ecx-warn:       #d97706;
  --ecx-radius:     12px;
}

/* --------------------------------------------------------------------------
   1. Card shell — equal heights, bottom-anchored footer, breathing room
   -------------------------------------------------------------------------- */

ul.product-box {
  border-color: var(--ecx-line);
}

ul.product-box li.product {
  border-color: var(--ecx-line);
  background: var(--ecx-surface);
  transition: box-shadow .22s ease, border-color .22s ease;
}

ul.product-box li.product:hover {
  box-shadow: 0 8px 28px -10px rgba(17, 20, 28, .18);
  border-color: transparent;
}

ul.product-box li.product .product-box-inner {
  display: flex;
  flex-direction: column;
}

ul.product-box li.product .info-product {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 12px 12px 16px;   /* bottom padding: content never touches the edge */
  text-align: right;
}

/* Seller line is hidden by the theme on archives — keep it out of the flow. */
ul.product-box li.product .author-Original {
  display: none !important;
}

/* --------------------------------------------------------------------------
   2. Corner badges — pulled out of the flow so every image starts at the
      same height whether the product is on sale or not
   -------------------------------------------------------------------------- */

ul.product-box li.product .head-archie-pro {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 65%;
  padding: 0;
  pointer-events: none;
}

body ul.product-box li.product .head-archie-pro .prs {
  background: var(--ecx-sale-soft) !important;
  color: var(--ecx-sale) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  padding: 5px 8px !important;
  margin: 0 !important;
  border-radius: 999px !important;
  white-space: nowrap;
}

body ul.product-box li.product .head-archie-pro #sales_timer_display {
  background: #f4f5f8;
  color: var(--ecx-ink-2);
  font-size: 10.5px !important;
  line-height: 1 !important;
  padding: 4px 7px !important;
  margin: 0 !important;
  border-radius: 999px !important;
  white-space: nowrap;
}

ul.product-box li.product .custom_label {
  top: 10px !important;
  left: 10px;
  right: auto;
  padding: 4px 8px;
  border-radius: 999px;
  z-index: 3;
}

ul.product-box li.product .custom_label span {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   3. Media
   -------------------------------------------------------------------------- */

ul.product-box li.product .thumb-pro {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 168px;
  margin: 8px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

ul.product-box li.product .thumb-pro img {
  width: auto !important;
  height: auto;
  max-width: 142px !important;
  max-height: 100%;
  object-fit: contain;
  transition: transform .35s ease;
}

/* Keep the gallery hover image centred inside the new fixed-height box. */
ul.product-box li.product .thumb-pro img.second-img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
}

ul.product-box li.product:hover .thumb-pro img {
  transform: scale(1.04);
}

/* --------------------------------------------------------------------------
   4. Title
   -------------------------------------------------------------------------- */

ul.product-box li.product .index-title-pro {
  margin: 0;
}

body ul.product-box li.product div.index-title-pro h2 {
  font-size: 13px !important;
  line-height: 22px;
  height: 44px;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--ecx-ink);
  text-align: right;
}

ul.product-box li.product .index-title-pro h2 a {
  color: inherit;
  transition: color .18s ease;
}

ul.product-box li.product:hover .index-title-pro h2 a {
  color: #000;
}

/* --------------------------------------------------------------------------
   5. Meta row — stock + rating
   -------------------------------------------------------------------------- */

ul.product-box li.product .flexed.stock_box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 9px;
  min-height: 16px;
}

ul.product-box li.product .stock-archive {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: var(--ecx-ok);
}

ul.product-box li.product .stock-archive::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

ul.product-box li.product .stock-archive i {
  display: none;
}

ul.product-box li.product .stock-archive p,
ul.product-box li.product .stock-archive span {
  margin: 0;
  line-height: 1;
}

/* Low stock ("N در انبار") reads amber, sold out reads grey. */
ul.product-box li.product .stock-archive:has(.stockon) {
  color: var(--ecx-warn);
}

ul.product-box li.product.outofstock .stock-archive {
  color: var(--ecx-ink-3);
}

ul.product-box li.product .rating_and_nummbercomment {
  margin: 0;
}

ul.product-box li.product .rating_product {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--ecx-line-soft) !important;
}

ul.product-box li.product .rating_product i {
  font-size: 11px;
  line-height: 1;
}

ul.product-box li.product .rating_product span.average_rating {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--ecx-ink-2);
}

/* --------------------------------------------------------------------------
   6. Colour swatches (variable products)
   -------------------------------------------------------------------------- */

.ecx-swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  margin: 0 0 10px;
}

.ecx-swatch {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ecx-swatch, #dcdfe6);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}

/* CSS-only tooltip: the colour name lives in data-name, no extra DOM, no JS. */
.ecx-swatch::after {
  content: attr(data-name);
  position: absolute;
  bottom: calc(100% + 7px);
  right: 50%;
  transform: translateX(50%) translateY(3px);
  z-index: 6;
  padding: 3px 7px;
  border-radius: 5px;
  background: #22242b;
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.ecx-swatch:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(50%) translateY(0);
}

.ecx-swatch-more {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 14px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ecx-line-soft);
  color: var(--ecx-ink-2);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  direction: ltr;
}

/* --------------------------------------------------------------------------
   7. Price block — bottom anchored, one clear hierarchy:
      row 1  discount pill + struck-through original price (small, muted)
      row 2  price actually paid (large, dark)
   -------------------------------------------------------------------------- */

ul.product-box li.product .index-prices-pro {
  float: none;
  width: 100%;
  height: auto;
  /* min-height = button height + padding-top + border, so the price column and
     the absolutely positioned button always occupy the same band and line up
     whether the price is one line or two. */
  min-height: 53px;
  margin-top: auto;                 /* pins the footer to the bottom of the card */
  padding: 12px 52px 0 0;           /* right gutter reserves room for the button */
  border-top: 1px solid var(--ecx-line);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

ul.product-box li.product .index-prices-pro .price_onsale_ar {
  display: block;
  text-align: left;
  line-height: 1.3;
}

/* Type is set on the <bdi> as well as the wrapping <span>: the theme sheet and
   the site's own Additional CSS both size the <bdi> directly, and since the
   <bdi> is an atomic inline nothing inherited from the span would reach it. */
ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount,
ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount bdi {
  font-size: 16px !important;
  font-weight: 800 !important;
  letter-spacing: -.2px;
  color: var(--ecx-ink) !important;
}

ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount {
  display: inline-block;
}

ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount bdi {
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
}

ul.product-box li.product .index-prices-pro .woocommerce-Price-currencySymbol {
  order: 1;
  margin: 0 !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  color: var(--ecx-ink-2);
}

/* Original price + discount pill */
ul.product-box li.product .index-prices-pro div del {
  display: flex !important;
  align-items: center;
  justify-content: left;
  gap: 6px;
  min-height: 20px;
  margin: 0;
  text-decoration: none;
}

ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount,
ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount bdi {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: var(--ecx-ink-3) !important;
  /* line-through has to be repeated on the <bdi>: an atomic inline does not
     inherit the decoration drawn by its ancestors. */
  text-decoration: line-through !important;
}

/* The currency unit is already spelled out on the price that is actually
   charged — repeating it on the struck-through line is just noise. */
ul.product-box li.product .index-prices-pro div del .woocommerce-Price-currencySymbol {
  display: none;
}

ul.product-box li.product .index-prices-pro div .index-discount-pro {
  float: none;
  order: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 20px;
  margin: 0;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--ecx-sale) !important;
  color: #fff !important;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
}

ul.product-box li.product .index-prices-pro div .index-discount-pro p {
  margin: 0 1px 0 0;
  line-height: 1;
  color: #fff !important;
}

ul.product-box li.product .index-prices-pro div ins {
  display: block;
  margin: 3px 0 0;
  background: transparent;
  text-decoration: none;
}

/* "Call for price" / out of stock message */
ul.product-box li.product .price_onsale_ar .call_pro {
  margin: 0;
  padding: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ecx-ink-3);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   8. Add to cart
   -------------------------------------------------------------------------- */

body ul.product-box li.product a.button.quick_add2cart,
body ul.product-box li.product .quick_add2cart.button {
  position: absolute !important;
  right: 12px !important;
  bottom: 16px !important;
  left: auto !important;
  top: auto !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border-radius: var(--ecx-radius) !important;
  font-size: 18px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 12px -5px rgba(0, 0, 0, .35);
  transition: transform .18s ease, box-shadow .18s ease !important;
}

/* The button stays visually 40px but the tap target is 48px, so it clears the
   44px minimum without turning into a slab in the corner of the card. */
body ul.product-box li.product .quick_add2cart.button::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  bottom: -4px;
  left: -4px;
}

body ul.product-box li.product .quick_add2cart.button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body ul.product-box li.product .quick_add2cart.button:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, .4);
}

body ul.product-box li.product .quick_add2cart.button:active {
  transform: translateY(0) scale(.95);
}

ul.product-box li.product a:focus-visible,
ul.product-box li.product .quick_add2cart:focus-visible {
  outline: 2px solid var(--ecx-ink);
  outline-offset: 2px;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  ul.product-box li.product .thumb-pro {
    height: 152px;
  }
  ul.product-box li.product .thumb-pro img {
    max-width: 128px !important;
  }
}

@media (max-width: 990px) {
  ul.product-box li.product {
    padding: 6px !important;
    border-radius: 16px;
  }

  ul.product-box li.product .info-product {
    padding: 8px 8px 12px !important;
  }

  ul.product-box li.product .thumb-pro {
    height: 132px;
    margin: 6px 0 10px;
  }

  ul.product-box li.product .thumb-pro img {
    max-width: 112px !important;
  }

  body ul.product-box li.product div.index-title-pro h2 {
    font-size: 12.5px !important;
    line-height: 21px !important;
    height: 42px !important;
    margin: 0 0 8px !important;
  }

  .ecx-swatches {
    gap: 4px;
    margin-bottom: 9px;
  }

  .ecx-swatch {
    width: 12px;
    height: 12px;
  }

  .ecx-swatch-more {
    height: 12px;
    padding: 0 4px;
    font-size: 10px;
  }

  ul.product-box li.product .index-prices-pro {
    min-height: 50px;
    padding: 11px 50px 0 0;
  }

  ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount,
  ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount bdi {
    font-size: 14.5px !important;
  }

  ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount,
  ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount bdi {
    font-size: 11px !important;
  }

  body ul.product-box li.product a.button.quick_add2cart,
  body ul.product-box li.product .quick_add2cart.button {
    right: 8px !important;
    bottom: 12px !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 17px !important;
  }
}

@media (max-width: 690px) {
  /* The theme locks cards to a fixed 305px on small screens, which clips the
     new swatch row. Height is driven by content again; the grid still keeps
     every card in a row the same height. */
  body ul.product-box li.product {
    height: auto !important;
  }
}

@media (max-width: 490px) {
  ul.product-box li.product .thumb-pro {
    height: 124px;
  }

  ul.product-box li.product .thumb-pro img {
    max-width: 104px !important;
  }

  body ul.product-box li.product div.index-title-pro h2 {
    font-size: 12px !important;
    line-height: 20px !important;
    height: 40px !important;
  }

  ul.product-box li.product .index-prices-pro {
    min-height: 47px;
    padding: 10px 46px 0 0;
  }

  ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount,
  ul.product-box li.product .index-prices-pro span.woocommerce-Price-amount bdi {
    font-size: 14px !important;
  }

  ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount,
  ul.product-box li.product .index-prices-pro div del span.woocommerce-Price-amount bdi {
    font-size: 10.5px !important;
  }

  body ul.product-box li.product a.button.quick_add2cart,
  body ul.product-box li.product .quick_add2cart.button {
    width: 36px !important;
    height: 36px !important;
    right: 6px !important;
    bottom: 8px !important;
  }
}

/* Touch devices have no hover: keep the swatch tooltip out of the way. */
@media (hover: none) {
  .ecx-swatch::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  ul.product-box li.product,
  ul.product-box li.product .thumb-pro img,
  ul.product-box li.product .quick_add2cart.button,
  .ecx-swatch::after {
    transition: none !important;
  }

  ul.product-box li.product:hover .thumb-pro img {
    transform: none;
  }
}
