/*
 * So Sanh 24H Astra Child 3.2.34 — UI presentation only.
 * Keep existing brand colors, comparison targets, store links and functionality.
 * Intentionally scoped to the existing SS24 front-end components.
 */

/* Product cards: same rhythm from card to card without replacing content. */
.ss-live-prices .ss24-wrap .ss24-grid,
.ss-category-results .ss24-wrap .ss24-grid,
.ss24-home-product-list .ss24-wrap .ss24-grid,
.ss-elementor-slot-homepage .ss24-wrap .ss24-grid {
  align-items: stretch;
  gap: 12px;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  height: 100%;
  min-width: 0;
  padding: 13px !important;
  border: 1px solid #e0e8f3;
  border-radius: 12px;
  box-shadow: none;
  background: #fff;
  overflow: hidden;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-product-image {
  flex: 0 0 157px;
  height: 157px !important;
  min-height: 157px !important;
  max-height: 157px !important;
  width: 100%;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 8px;
  padding: 0 0 34px;
  overflow: hidden;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-product-image > img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 115px !important;
  max-height: 115px !important;
  object-fit: contain;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-product-image > .ss24-image-placeholder:not([hidden]) {
  height: 115px;
  max-height: 115px;
  width: 100%;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > h3 {
  flex: 0 0 58px;
  min-height: 58px !important;
  max-height: 58px !important;
  width: 100%;
  margin: 0 0 6px !important;
  overflow: hidden;
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow-wrap: break-word;
  word-break: normal;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.45 !important;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > h3 .ss24-name-link {
  color: inherit;
  font-weight: inherit !important;
  line-height: inherit !important;
  font-size: inherit !important;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-price {
  flex: 0 0 43px;
  min-height: 43px;
  max-height: 43px !important;
  overflow: hidden;
  width: 100%;
  margin: 0 !important;
  font-size: 17px !important;
  font-weight: 800;
  line-height: 1.32;
  color: #e65b25;
  overflow-wrap: normal;
  word-break: normal;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-shop-count {
  flex: 0 0 auto;
  min-height: 22px !important;
  width: 100%;
  margin: 2px 0 5px !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
  color: #637890;
  overflow-wrap: break-word;
  white-space: normal !important;
}
/* Only counts receive a cart icon; store-view merchant names stay unchanged. */
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-shop-count[data-ss24-count]::before {
  content: '🛒';
  display: inline-block;
  font-size: 12px;
  margin-right: 4px;
  vertical-align: -1px;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-coupon-hint,
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-card-stores {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  margin: 5px 0 !important;
}
/* Buttons hug text, keep their original blue/orange brand colors. */
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > a.ss24-buy {
  display: inline-flex !important;
  flex: 0 0 auto;
  width: max-content !important;
  max-width: 100% !important;
  min-width: 0 !important;
  min-height: 34px !important;
  height: auto !important;
  margin: auto auto 0 !important;
  padding: 7px 11px !important;
  align-items: center;
  justify-content: center;
  align-self: center;
  border: 1px solid #1264d6 !important;
  border-radius: 8px !important;
  background: #1264d6;
  color: #fff !important;
  text-align: center;
  white-space: normal !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
  font-weight: 700 !important;
  box-sizing: border-box;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card .ss24-hover-compare {
  bottom: 4px !important;
  left: 50%;
  width: max-content !important;
  max-width: calc(100% - 8px) !important;
  min-height: 32px;
  padding: 6px 11px !important;
  border: 1px solid #f97316 !important;
  border-radius: 8px !important;
  background: #f97316;
  box-shadow: none !important;
  text-align: center;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  box-sizing: border-box;
}
.ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card a:focus-visible,
.ss24-detail-v2 a:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 2px;
}

/* Detailed product: never squeeze merchants into a single-letter column. */
.ss24-detail-v2 .ss24-detail-topshop,
.ss24-detail-v2 .ss24-detail-store {min-width: 0;}
.ss24-detail-v2 .ss24-detail-topshop-name {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  overflow-wrap: normal;
  word-break: normal;
}
.ss24-detail-v2 .ss24-detail-topshop-name > span:last-child,
.ss24-detail-v2 .ss24-detail-store > span:last-child {
  display: block;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}
.ss24-detail-v2 .ss24-detail-topshop-name .ss24-merchant-logo {
  flex: 0 0 30px;
  width: 30px;
}
.ss24-detail-v2 .ss24-detail-go {
  width: max-content !important;
  max-width: 100% !important;
  min-height: 34px;
  border: 1px solid #1264d6;
  border-radius: 8px;
  padding: 7px 12px !important;
  box-sizing: border-box;
  white-space: nowrap;
}

/* Astra's existing scroll-to-top is spaced above the unchanged AI launcher. */
#ast-scroll-top,
.ast-scroll-to-top {
  right: 14px !important;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 99990 !important;
}

@media (max-width: 700px) {
  .ss-live-prices .ss24-wrap .ss24-grid,
  .ss-category-results .ss24-wrap .ss24-grid,
  .ss24-home-product-list .ss24-wrap .ss24-grid,
  .ss-elementor-slot-homepage .ss24-wrap .ss24-grid,
  .ss24-wrap .ss24-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    align-items: stretch;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card {padding: 9px !important;border-radius: 10px;}
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-product-image {
    flex-basis: 135px;
    height: 135px !important;
    min-height: 135px !important;
    max-height: 135px !important;
    padding: 0 0 32px;
    margin-bottom: 6px;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-product-image > img {
    height: 98px !important;
    max-height: 98px !important;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > h3 {
    flex-basis: 55px;
    min-height: 55px !important;
    max-height: 55px !important;
    font-size: 12px !important;
    line-height: 1.48 !important;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-price {
    flex-basis: 39px;
    min-height: 39px !important;
    max-height: 39px !important;
    font-size: 14px !important;
    line-height: 1.36;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-shop-count {
    font-size: 11px !important;
    min-height: 20px !important;
    margin: 2px 0 4px !important;
  }
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card .ss24-hover-compare {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translate(-50%, 0) !important;
    bottom: 2px !important;
    padding: 6px 8px !important;
    min-height: 30px;
    font-size: 11px !important;
  }
  /* A multi-merchant card already has the orange compare button above.
   * Hide the redundant blue comparison button only on small screens. */
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > a.ss24-buy.ss24-compare-action {
    display: none !important;
  }
  /* Keep the blue 'Đến nơi bán' action for single-merchant products. */
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > a.ss24-buy:not(.ss24-compare-action) {
    margin-top: auto !important;
    min-height: 31px !important;
    font-size: 11px !important;
    padding: 6px 8px !important;
  }
  /* Gợi ý nơi bán: name + price on first row, compact action on second. */
  .ss24-detail-v2 .ss24-detail-topshops-list {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 9px !important;
  }
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 7px 10px !important;
    align-items: center;
    min-width: 0;
    width: 100%;
    padding: 10px !important;
  }
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop > .ss24-detail-topshop-name {
    grid-column: 1;
    grid-row: 1;
  }
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop > strong {
    grid-column: 2;
    grid-row: 1;
    font-size: 14px !important;
    white-space: nowrap;
  }
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop > a.ss24-detail-go {
    grid-column: 1/-1;
    grid-row: 2;
    justify-self: end;
    width: max-content !important;
    min-height: 31px;
    font-size: 12px !important;
    padding: 6px 11px !important;
  }
  .ss24-detail-v2 .ss24-detail-offer {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 7px 10px !important;
    padding: 11px !important;
  }
  .ss24-detail-v2 .ss24-detail-offer > .ss24-detail-store {
    grid-column: 1/-1 !important;
    grid-row: 1;
  }
  .ss24-detail-v2 .ss24-detail-offer > .ss24-detail-offer-title {
    grid-column: 1/-1 !important;
    grid-row: 2;
  }
  .ss24-detail-v2 .ss24-detail-offer > .ss24-detail-offer-price {
    grid-column: 1;
    grid-row: 3;
    min-width: 0;
    white-space: normal;
  }
  .ss24-detail-v2 .ss24-detail-offer > div:nth-of-type(3) {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
    min-width: 0;
  }
  /* Do not modify the AI launcher or behavior. Just space the separate scroll button. */
  #ast-scroll-top,
  .ast-scroll-to-top {
    right: max(13px, env(safe-area-inset-right, 0px)) !important;
    bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
@media (max-width: 360px) {
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card {padding: 7px !important;}
  .ss24-wrap .ss24-grid > .ss24-card.ss24-hover-card > .ss24-price {font-size: 13px !important;}
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop {grid-template-columns: minmax(0, 1fr) !important;}
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop > strong,
  .ss24-detail-v2 .ss24-detail-topshops-list > .ss24-detail-topshop > a.ss24-detail-go {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }
}
