/* ═══════════════════════════════════════════════════════════════════════
   SAFO — Unified Product Cards
   Final cross-page override loaded last to normalize product cards
   across marketplace, store, subcategory, seller and mobile feed views.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --safo-card-radius: 18px;
  --safo-card-radius-sm: 14px;
  --safo-card-border: rgba(15, 23, 42, 0.08);
  --safo-card-border-hover: rgba(255, 106, 0, 0.22);
  --safo-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --safo-card-shadow-hover: 0 18px 40px rgba(15, 23, 42, 0.12);
  --safo-card-surface: #ffffff;
  --safo-card-muted: #f8fafc;
  --safo-card-image-bg: linear-gradient(180deg, #fbfdff 0%, #f3f6fb 100%);
  --safo-card-title-lines: 2;
}

/* ── Unified product grids ─────────────────────────────────────────── */
.products-grid,
.premium-products-grid,
.subcat-products-grid,
.subcat-trending-grid,
.seller-products-grid,
.mx-feed-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: clamp(10px, 1.4vw, 18px) !important;
  align-items: stretch !important;
}

.products-grid,
.premium-products-grid,
.subcat-products-grid,
.subcat-trending-grid {
  padding-inline: clamp(8px, 1.8vw, 18px) !important;
  padding-bottom: clamp(12px, 1.8vw, 18px) !important;
}

.products-grid > *,
.premium-products-grid > *,
.subcat-products-grid > *,
.subcat-trending-grid > *,
.seller-products-grid > *,
.mx-feed-grid > * {
  min-width: 0;
  height: 100%;
}

@media (min-width: 640px) {
  .products-grid,
  .premium-products-grid,
  .subcat-products-grid,
  .subcat-trending-grid,
  .seller-products-grid,
  .mx-feed-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 992px) {
  .products-grid,
  .premium-products-grid,
  .subcat-products-grid,
  .subcat-trending-grid,
  .seller-products-grid,
  .mx-feed-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 1400px) {
  .products-grid,
  .premium-products-grid,
  .subcat-products-grid,
  .subcat-trending-grid,
  .seller-products-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
}

/* ── Shared card shell ─────────────────────────────────────────────── */
.product-card,
.product-card--pro,
.product-card-seller,
.mx-product-card {
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0;
  height: 100% !important;
  border-radius: var(--safo-card-radius) !important;
  border: 1px solid var(--safo-card-border) !important;
  background: var(--safo-card-surface) !important;
  box-shadow: var(--safo-card-shadow) !important;
  overflow: hidden !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease !important;
  backface-visibility: hidden;
}

.product-card:hover,
.product-card--pro:hover,
.product-card-seller:hover,
.mx-product-card:hover {
  transform: translateY(-4px) !important;
  border-color: var(--safo-card-border-hover) !important;
  box-shadow: var(--safo-card-shadow-hover) !important;
}

@media (hover: none) {
  .product-card:hover,
  .product-card--pro:hover,
  .product-card-seller:hover,
  .mx-product-card:hover {
    transform: none !important;
  }
}

/* ── Image areas ───────────────────────────────────────────────────── */
.product-card-media,
.product-card-img-wrap,
.product-card-seller .product-card-img,
.mx-product-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.04 !important;
  overflow: hidden !important;
  background: var(--safo-card-image-bg) !important;
  border-radius: 0 !important;
}

.product-card-media .product-card-img,
.product-card-img-wrap .product-card-img,
.product-card-seller .product-card-img > img,
.mx-product-thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  padding: clamp(8px, 1vw, 12px);
  background: transparent !important;
  transform: none !important;
  transition: transform 0.22s ease !important;
}

.product-card:hover .product-card-media .product-card-img,
.product-card:hover .product-card-img-wrap .product-card-img,
.product-card-seller:hover .product-card-img > img,
.mx-product-card:hover .mx-product-thumb img {
  transform: scale(1.03) !important;
}

/* ── Main public card layout ───────────────────────────────────────── */
.product-card-body--pro,
.product-card-body,
.mx-product-body,
.mx-product-body--dense {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-height: 0;
  padding: 12px 12px 14px !important;
  gap: 10px !important;
}

.product-card-price-line,
.product-card-price-row,
.product-card-price-row--compact,
.mx-product-price-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  gap: 6px !important;
  margin: 0 !important;
  min-height: 26px;
}

.product-card-price-line .product-card-price,
.product-card-price,
.mx-product-price {
  color: #d9480f !important;
  font-weight: 900 !important;
  line-height: 1.08 !important;
  letter-spacing: -0.02em;
}

.product-card-price-line .product-card-price,
.product-card-price {
  font-size: clamp(15px, 1.05vw, 18px) !important;
}

.mx-product-price {
  font-size: clamp(14px, 1vw, 17px) !important;
}

.old-price,
.product-card-price-line .old-price,
.mx-product-old-price {
  font-size: 11px !important;
  color: #94a3b8 !important;
  text-decoration: line-through !important;
}

.product-card-title--pro,
.product-card-title,
.mx-product-title {
  margin: 0 !important;
  color: #065F46 !important;
  font-weight: 700 !important;
  line-height: 1.5 !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: var(--safo-card-title-lines) !important;
  overflow: hidden !important;
}

.product-card-title--pro,
.product-card-title {
  font-size: 13px !important;
  min-height: calc(13px * 1.5 * 2);
}

.mx-product-title {
  font-size: 12.5px !important;
  min-height: calc(12.5px * 1.5 * 2);
}

.product-card-meta-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
}

.product-card-meta-box {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  min-height: 58px;
  padding: 9px 10px !important;
  border-radius: 12px !important;
  background: #f8fafc !important;
  border: 1px solid rgba(15, 23, 42, 0.05) !important;
}

.product-card-meta-box strong,
.product-card-meta-box span,
.product-card-supplier-main strong,
.product-card-supplier-main span,
.product-card-meta span,
.product-card-service-chip,
.product-card-rating {
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-service-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
  gap: 6px !important;
  min-height: 32px;
}

.product-card-service-chip {
  min-height: 28px !important;
  padding-inline: 10px !important;
  border-radius: 999px !important;
  background: #f8fafc !important;
  border: 1px solid rgba(15, 23, 42, 0.06) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  white-space: nowrap;
}

.product-card-supplier-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  min-height: 58px;
  margin-top: auto !important;
  padding: 10px 12px !important;
  border-radius: var(--safo-card-radius-sm) !important;
  background: linear-gradient(180deg, #fbfdff 0%, #f8fafc 100%) !important;
  border: 1px solid rgba(15, 23, 42, 0.06) !important;
}

.product-card-supplier-main {
  min-width: 0;
  flex: 1 1 auto;
}

.product-card-supplier-main strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px !important;
  white-space: nowrap;
}

.product-card-supplier-main span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 11px !important;
  line-height: 1.45 !important;
  color: #64748b !important;
}

.product-card-supplier-link {
  flex-shrink: 0;
  font-size: 12px !important;
  font-weight: 800 !important;
}

.product-card-action-row {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
  margin-top: 10px !important;
}

.product-card-cta {
  min-height: 42px !important;
  border-radius: 12px !important;
  padding-inline: 10px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  white-space: nowrap;
}

/* ── Legacy / owner cards ─────────────────────────────────────────── */
.product-card:not(.product-card--pro) .product-card-body {
  justify-content: space-between;
}

.product-card:not(.product-card--pro) .product-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 22px;
  font-size: 11px;
  color: #64748b;
}

/* ── Seller dashboard cards ───────────────────────────────────────── */
.product-card-seller .product-card-body {
  padding: 12px !important;
  gap: 8px !important;
}

.product-card-seller .product-card-title {
  font-size: 13px !important;
  min-height: calc(13px * 1.5 * 2);
}

.product-card-seller .product-card-price {
  font-size: 16px !important;
  color: #d9480f !important;
}

.product-card-seller .product-card-meta {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px !important;
  font-size: 11px !important;
  color: #64748b !important;
}

.product-card-seller .product-card-meta span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.05);
  white-space: nowrap;
}

.product-card-seller .product-card-actions {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  padding: 0 12px 12px !important;
  margin-top: auto !important;
}

.product-card-seller .product-card-menu-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12) !important;
}

.product-card-seller .badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 3;
}

/* ── Subcategory list view ────────────────────────────────────────── */
.subcat-products-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

.subcat-products-list .product-card,
.products-grid.list-view .product-card,
.products-grid.list-view .product-card--pro {
  display: grid !important;
  grid-template-columns: minmax(132px, 160px) minmax(0, 1fr) !important;
  align-items: stretch !important;
}

.subcat-products-list .product-card-media,
.subcat-products-list .product-card-img-wrap,
.products-grid.list-view .product-card-media,
.products-grid.list-view .product-card-img-wrap {
  aspect-ratio: auto !important;
  min-height: 100%;
  height: 100%;
}

.subcat-products-list .product-card-body--pro,
.subcat-products-list .product-card-body,
.products-grid.list-view .product-card-body--pro,
.products-grid.list-view .product-card-body {
  padding: 12px 12px 12px 14px !important;
}

/* ── Mobile refinements ───────────────────────────────────────────── */
@media (max-width: 639px) {
  .product-card,
  .product-card--pro,
  .product-card-seller,
  .mx-product-card {
    border-radius: 16px !important;
  }

  .product-card-body--pro,
  .product-card-body,
  .mx-product-body,
  .mx-product-body--dense {
    padding: 10px 10px 12px !important;
    gap: 8px !important;
  }

  .product-card-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .product-card-action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .product-card-cta--primary {
    grid-column: 1 / -1;
  }

  .subcat-products-list .product-card,
  .products-grid.list-view .product-card,
  .products-grid.list-view .product-card--pro {
    grid-template-columns: 1fr !important;
  }

  .subcat-products-list .product-card-media,
  .subcat-products-list .product-card-img-wrap,
  .products-grid.list-view .product-card-media,
  .products-grid.list-view .product-card-img-wrap {
    aspect-ratio: 1 / 1.04 !important;
  }
}

/* ── Seller dashboard wrapper (isolated from public seller label) ─── */
.seller-dashboard-card {
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0;
  height: 100% !important;
  border-radius: var(--safo-card-radius) !important;
  border: 1px solid var(--safo-card-border) !important;
  background: var(--safo-card-surface) !important;
  box-shadow: var(--safo-card-shadow) !important;
  overflow: hidden !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease !important;
  backface-visibility: hidden;
}

.seller-dashboard-card:hover {
  transform: translateY(-4px) !important;
  border-color: var(--safo-card-border-hover) !important;
  box-shadow: var(--safo-card-shadow-hover) !important;
}

.seller-dashboard-card .product-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.04 !important;
  overflow: hidden !important;
  background: var(--safo-card-image-bg) !important;
  border-radius: 0 !important;
}

.seller-dashboard-card .product-card-img > img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  padding: clamp(8px, 1vw, 12px);
  background: transparent !important;
  transform: none !important;
  transition: transform 0.22s ease !important;
}

.seller-dashboard-card:hover .product-card-img > img {
  transform: scale(1.03) !important;
}

.seller-dashboard-card .product-card-body {
  padding: 12px !important;
  gap: 8px !important;
}

.seller-dashboard-card .product-card-title {
  font-size: 13px !important;
  min-height: calc(13px * 1.5 * 2);
}

.seller-dashboard-card .product-card-price {
  font-size: 16px !important;
  color: #d9480f !important;
}

.seller-dashboard-card .product-card-meta {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px !important;
  font-size: 11px !important;
  color: #64748b !important;
}

.seller-dashboard-card .product-card-meta span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.05);
  white-space: nowrap;
}

.seller-dashboard-card .product-card-actions {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  padding: 0 12px 12px !important;
  margin-top: auto !important;
}

.seller-dashboard-card .product-card-menu-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12) !important;
}

.seller-dashboard-card .badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 3;
}

@media (max-width: 639px) {
  .seller-dashboard-card {
    border-radius: 16px !important;
  }
}

/* ── Strong consistency helpers ───────────────────────────────────── */
.product-card .discount-tag,
.product-card .product-card-discount-badge,
.mx-product-card .mx-badge--sale {
  font-weight: 800 !important;
}

.product-card .product-card-img,
.product-card-seller img,
.mx-product-card img {
  image-rendering: auto;
}


/* ──────────────────────────────────────────────────────────────────────────────
   Alibaba-density mobile override
   Reduces true card height, removes vertical waste, increases media share,
   and prevents row-equalization from making short cards unnecessarily tall.
   ────────────────────────────────────────────────────────────────────────────── */

.products-grid,
.premium-products-grid,
.subcat-products-grid,
.subcat-trending-grid,
.seller-products-grid,
.mx-feed-grid {
  gap: 8px !important;
  align-items: start !important;
}

.products-grid > *,
.premium-products-grid > *,
.subcat-products-grid > *,
.subcat-trending-grid > *,
.seller-products-grid > *,
.mx-feed-grid > * {
  height: auto !important;
  align-self: start !important;
}

.product-card,
.product-card--pro,
.product-card-seller,
.mx-product-card {
  height: auto !important;
  min-height: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07) !important;
}

.product-card:hover,
.product-card--pro:hover,
.product-card-seller:hover,
.mx-product-card:hover {
  transform: none !important;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.10) !important;
}

.product-card-media,
.product-card-img-wrap,
.product-card-seller .product-card-img,
.mx-product-thumb {
  aspect-ratio: 1 / 1 !important;
  background: #f8fafc !important;
}

.product-card-media .product-card-img,
.product-card-img-wrap .product-card-img,
.product-card-seller .product-card-img > img,
.mx-product-thumb img,
.product-card .product-card-img,
.mx-product-card img {
  object-fit: cover !important;
  object-position: center !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
}

.product-card-body,
.product-card-body--pro,
.mx-product-body,
.mx-product-body--dense {
  padding: 7px 8px 8px !important;
  gap: 4px !important;
  min-height: 0 !important;
}

.product-card-price-line,
.product-card-price-row,
.product-card-price-row--compact,
.mx-product-price-row {
  gap: 4px !important;
  min-height: 0 !important;
}

.product-card-price-line .product-card-price,
.product-card-price,
.mx-product-price {
  font-size: 14px !important;
  line-height: 1.05 !important;
}

.old-price,
.product-card-price-line .old-price,
.mx-product-old-price {
  font-size: 10px !important;
  line-height: 1.1 !important;
}

.product-card-title--pro,
.product-card-title,
.mx-product-title {
  font-size: 11.25px !important;
  line-height: 1.32 !important;
  min-height: calc(11.25px * 1.32 * 2) !important;
  font-weight: 600 !important;
}

.product-card-meta-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 4px !important;
}

.product-card-meta-box {
  min-height: 34px !important;
  padding: 4px 6px !important;
  border-radius: 8px !important;
  background: #f8fafc !important;
}

.product-card-meta-box strong {
  margin: 0 0 1px !important;
  font-size: 9px !important;
  line-height: 1.1 !important;
  font-weight: 800 !important;
  color: #64748b !important;
}

.product-card-meta-box span {
  font-size: 10px !important;
  line-height: 1.2 !important;
  font-weight: 700 !important;
  color: #065F46 !important;
  white-space: nowrap;
}

.product-card-service-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 4px !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.product-card-service-chip {
  min-height: 20px !important;
  padding-inline: 6px !important;
  font-size: 9.5px !important;
  line-height: 1 !important;
  border-radius: 999px !important;
  white-space: nowrap !important;
}

.product-card-service-row .product-card-service-chip:nth-child(n+3) {
  display: none !important;
}

.product-card-supplier-row {
  min-height: 0 !important;
  margin-top: 0 !important;
  padding: 6px 8px !important;
  gap: 6px !important;
  border-radius: 10px !important;
}

.product-card-supplier-main strong {
  margin-bottom: 1px !important;
  font-size: 11px !important;
  line-height: 1.2 !important;
}

.product-card-supplier-main span {
  -webkit-line-clamp: 1 !important;
  font-size: 9.5px !important;
  line-height: 1.2 !important;
}

.product-card-supplier-link {
  min-height: 28px !important;
  padding: 0 8px !important;
  border-radius: 8px !important;
  font-size: 10px !important;
  line-height: 1 !important;
}

.product-card-action-row {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 5px !important;
  margin-top: 2px !important;
}

.product-card-cta {
  min-height: 31px !important;
  height: 31px !important;
  padding-inline: 6px !important;
  border-radius: 8px !important;
  font-size: 10px !important;
  line-height: 1 !important;
}

.product-card-cta svg,
.product-card-floating-btn svg {
  width: 13px !important;
  height: 13px !important;
}

.product-card-top-actions {
  padding: 6px !important;
}

.product-card-pill-stack {
  gap: 4px !important;
}

.product-card-pill,
.product-card-discount-badge,
.mx-badge {
  min-height: 18px !important;
  padding: 0 6px !important;
  font-size: 9px !important;
  border-radius: 4px !important;
}

.product-card-floating-btn {
  width: 28px !important;
  height: 28px !important;
  border-radius: 8px !important;
}

.mx-product-body,
.mx-product-body--dense {
  padding: 6px 8px 8px !important;
}

.mx-product-title {
  min-height: calc(11px * 1.32 * 2) !important;
}

.mx-product-actions,
.mx-product-meta,
.mx-product-signal-row {
  display: none !important;
}

@media (max-width: 639px) {
  .product-card,
  .product-card--pro,
  .product-card-seller,
  .mx-product-card {
    border-radius: 12px !important;
  }

  .product-card-body,
  .product-card-body--pro,
  .mx-product-body,
  .mx-product-body--dense {
    padding: 6px 7px 7px !important;
    gap: 4px !important;
  }

  .product-card-meta-box {
    min-height: 32px !important;
    padding: 4px 5px !important;
  }

  .product-card-meta-box strong {
    font-size: 8.5px !important;
  }

  .product-card-meta-box span {
    font-size: 9.5px !important;
  }

  .product-card-supplier-row {
    padding: 5px 7px !important;
  }

  .product-card-action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .product-card-cta--primary {
    grid-column: auto !important;
  }

  .product-card-cta {
    min-height: 30px !important;
    height: 30px !important;
    font-size: 9.75px !important;
    padding-inline: 4px !important;
  }
}
