/* Shop grid fixes: tight card spacing, button gap, carted state */

/* ---- Card body: stack content at the top, no stretched gaps ---- */
html body ul.products.products li.product.product .astra-shop-summary-wrap,
html body ul.products.products li.product.product .astra-shop-summary-wrap {
  justify-content: flex-start !important;
  padding: 12px 12px 0 !important;
  gap: 0 !important;
}

html body ul.products.products li.product.product .byte-card-meta-bar {
  margin: 0 0 8px !important;
}

html body ul.products.products li.product.product .ast-loop-product__link {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Title: smaller so the full name fits, up to 3 lines, no extra padding */
html body ul.products.products li.product.product .woocommerce-loop-product__title,
html body ul.products.products li.product.product h2.woocommerce-loop-product__title {
  font-size: 0.8rem !important;
  font-weight: 800 !important;
  line-height: 1.3 !important;
  letter-spacing: 0.01em !important;
  padding: 0 !important;
  margin: 0 0 8px !important;
  min-height: 0 !important;
  -webkit-line-clamp: 3 !important;
  overflow-wrap: anywhere !important;
}

@media (max-width: 767px) {
  html body ul.products.products li.product.product .woocommerce-loop-product__title,
  html body ul.products.products li.product.product h2.woocommerce-loop-product__title {
    font-size: 0.74rem !important;
  }
}

/* Price: no double padding */
html body ul.products.products li.product.product .price,
html body ul.products.products li.product.product .price {
  padding: 0 !important;
  margin: 0 0 12px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
}

/* ---- Button row: pinned to the bottom, more space between buttons ---- */
html body ul.products.products li.product.product .byte-loop-btn-row {
  gap: 14px !important;
  padding: 10px 12px 12px !important;
  margin: auto -12px 0 !important;
  width: calc(100% + 24px) !important;
  overflow: visible !important;
}

html body ul.products.products li.product.product .byte-loop-btn-row a.button {
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 11px 6px !important;
  font-size: 0.74rem !important;
  border: 2px solid #000000 !important;
  box-shadow: none !important;
  white-space: nowrap !important;
}

html body ul.products.products li.product.product .byte-loop-btn-row a.button.add_to_cart_button,
html body ul.products.products li.product.product .byte-loop-btn-row a.button.byte-add-link {
  background: #000000 !important;
  color: #FFFFFF !important;
}

html body ul.products.products li.product.product .byte-loop-btn-row a.button.byte-buy-now-btn {
  background: #000000 !important;
  color: #FFFFFF !important;
}

html body ul.products.products li.product.product .byte-loop-btn-row a.button.byte-buy-now-btn:hover,
html body ul.products.products li.product.product .byte-loop-btn-row a.button.add_to_cart_button:not(.byte-in-cart):hover,
html body ul.products.products li.product.product .byte-loop-btn-row a.button.byte-add-link:hover {
  background: #222222 !important;
  color: #FFFFFF !important;
}

/* ---- Carted state: blue "✓ View cart", hover shows red "✕ Remove" ---- */
html body ul.products.products li.product.product .byte-loop-btn-row a.button.add_to_cart_button.byte-in-cart {
  background: var(--lms-primary, #2563EB) !important;
  color: #FFFFFF !important;
}

html body ul.products.products li.product.product .byte-loop-btn-row a.byte-in-cart .byte-lbl-remove {
  display: none !important;
}

@media (hover: hover) {
  html body ul.products.products li.product.product .byte-loop-btn-row a.button.add_to_cart_button.byte-in-cart:not(.byte-just-added):hover {
    background: #DC2626 !important;
    color: #FFFFFF !important;
  }
  html body ul.products.products li.product.product .byte-loop-btn-row a.byte-in-cart:not(.byte-just-added):hover .byte-lbl-cart {
    display: none !important;
  }
  html body ul.products.products li.product.product .byte-loop-btn-row a.byte-in-cart:not(.byte-just-added):hover .byte-lbl-remove {
    display: inline !important;
  }
}

html body ul.products.products li.product.product .byte-loop-btn-row a.button.loading {
  opacity: 0.6 !important;
  pointer-events: none !important;
}

/* No extra tick/spinner icons from WooCommerce or Astra on grid buttons */
html body ul.products.products li.product.product .byte-loop-btn-row a.button::before,
html body ul.products.products li.product.product .byte-loop-btn-row a.button::after,
html body ul.products.products li.product.product .byte-loop-btn-row a.button.added::after,
html body ul.products.products li.product.product .byte-loop-btn-row a.button.loading::after {
  content: none !important;
  display: none !important;
}

/* WooCommerce's own "View cart" link would break the two-button row */
html body ul.products.products li.product.product .byte-loop-btn-row .added_to_cart {
  display: none !important;
}

/* Astra's bag icon / "Select options" button on the image: not wanted (Sale badge stays) */
html body ul.products.products li.product.product .ast-on-card-button:not(.ast-onsale-card),
html body ul.products.products li.product.product .ast-card-action-tooltip {
  display: none !important;
}

/* Out of stock: single full-width READ MORE */
html body ul.products.products li.product.product .byte-loop-btn-row.single-btn a.button {
  flex: 1 1 100% !important;
  background: #000000 !important;
  color: #FFFFFF !important;
}

@media (max-width: 380px) {
  html body ul.products.products li.product.product .byte-loop-btn-row { gap: 10px !important; padding: 8px 10px 10px !important; }
  html body ul.products.products li.product.product .byte-loop-btn-row a.button { font-size: 0.75rem !important; padding: 10px 4px !important; }
}

/* Title + buttons scale with the card's own width (shop 4-col, home 2-col, mobile) */
html body ul.products.products li.product.product {
  container-type: inline-size !important;
}

@supports (font-size: 1cqi) {
  html body ul.products.products li.product.product h2.woocommerce-loop-product__title,
  html body ul.products.products li.product.product .woocommerce-loop-product__title {
    font-size: clamp(0.8rem, 4.2cqi, 1.1rem) !important;
  }
  html body ul.products.products li.product.product .byte-loop-btn-row a.button {
    font-size: clamp(0.75rem, 3.4cqi, 0.92rem) !important;
    padding-top: clamp(10px, 2.6cqi, 14px) !important;
    padding-bottom: clamp(10px, 2.6cqi, 14px) !important;
  }
}

/* Button text always vertically + horizontally centered */
html body ul.products.products li.product.product .byte-loop-btn-row a.button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 1.15 !important;
  height: auto !important;
}
