/*
Theme Name:    Xstore child
Theme URI:     https://xstore.8theme.com
Description:   XStore child theme CSS — equal height product cards & consistent title area
Author:        8theme
Template:      xstore
Version:       1.1 (Fixed for checkout page)
Text Domain:   xstore-child
*/

/* =======
    CORE FIX
    ======= */

/* Make each product a vertical flex container so inner parts can stretch */
.woocommerce ul.products li.product,
ul.products li.product,
.products li.product,
.xstore-products .product-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

/* Ensure common inner wrappers (theme-specific names) also stretch */
.woocommerce ul.products li.product > .product-inner,
.woocommerce ul.products li.product .product-inner,
.woocommerce ul.products li.product .product-wrap,
.woocommerce ul.products li.product .product-block,
.woocommerce ul.products li.product .product-card,
.xstore-products .product-item .product-content {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

/* Reserve vertical space for product title (2 lines) so short titles don't collapse.
   --- THIS BLOCK IS NOW FIXED with more specific selectors --- */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
ul.products li.product .woocommerce-loop-product__title,
.products li.product .woocommerce-loop-product__title,
.products li.product .product-title, /* MORE SPECIFIC */
.products li.product .product-name, /* MORE SPECIFIC */
.woocommerce-loop-product__title {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;           /* visible lines */
  overflow: hidden !important;
  line-height: 1.2em !important;
  min-height: calc(1.2em * 2) !important;      /* reserve vertical space for 2 lines */
  margin: 0 0 0.5rem !important;
  font-weight: 600 !important;
  word-break: break-word !important;
}

/* Push price / add-to-cart / actions to bottom of the card */
.woocommerce ul.products li.product .price,
.woocommerce ul.products li.product .product-buttons,
.woocommerce ul.products li.product .add-to-cart,
.woocommerce ul.products li.product .product-actions,
.woocommerce ul.products li.product .product-meta,
.product-item .product-footer,
.product-card .product-footer {
  margin-top: auto !important;
  align-self: stretch !important;
}

/* Make images predictable: keep aspect ratio and not collapse */
.woocommerce ul.products li.product img,
.products li.product img,
.product-image img,
.product-thumbnail img,
.product-card img {
  width: 100% !important;
  height: auto !important;
  display: block !important;
  object-fit: contain !important;
}

/* Keep thumbnail container from collapsing */
.woocommerce ul.products li.product .product-thumbnail,
ul.products li.product .product-thumbnail,
.products li.product .product-thumbnail,
.product-image {
  width: 100% !important;
  display: block !important;
}

/* spacing between product cards (works with grid/flex) */
.woocommerce ul.products {
  gap: 1rem !important;
}

/* Prevent forced width conflicts with theme grid */
.woocommerce ul.products li.product,
ul.products li.product {
  width: auto !important;
}

/* Break long words safely
   --- THIS BLOCK IS ALSO FIXED with more specific selectors --- */
.products li.product .woocommerce-loop-product__title,
.products li.product .product-title,
.products li.product .product-name {
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

/* Smooth image hover (optional) */
.woocommerce ul.products li.product img,
.product-image img {
  transition: transform .25s ease, opacity .25s ease !important;
}

/* ========
    RESPONSIVE
    ======== */

/* Tablet: allow up to 3-line titles and increase reserved height */
@media (max-width: 992px) {
  .woocommerce ul.products li.product .woocommerce-loop-product__title,
  .products li.product .woocommerce-loop-product__title,
  .products li.product .product-title { /* MORE SPECIFIC */
    -webkit-line-clamp: 3 !important;
    min-height: calc(1.2em * 3) !important;
  }
  .woocommerce ul.products { gap: 0.9rem !important; }
}

/* Mobile: keep compact */
@media (max-width: 480px) {
  .woocommerce ul.products li.product .woocommerce-loop-product__title,
  .products li.product .woocommerce-loop-product__title {
    -webkit-line-clamp: 2 !important;
    min-height: calc(1.1em * 2) !important;
    font-size: 0.96rem !important;
  }
  .woocommerce ul.products { gap: 0.6rem !important; }
}

/* ========
    FALLBACKS
    ======== */

/* XStore / Dokan specific fallbacks (extra selectors) */
.xstore-products .product-title,
.xstore-products .product-name,
.xstore-product .product-title,
.dokan-product .product-title {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  min-height: calc(1.2em * 2) !important;
}