/* Sprint 40 — structural product-card footer fix.
   Loaded last to neutralise older fixed-height combinations that could clip
   View details / Add to cart below the visible card boundary. */

article.pcv2-card {
  --pcv2-card-height: 600px;
  --pcv2-media-height: 244px;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  height: var(--pcv2-card-height) !important;
  min-height: var(--pcv2-card-height) !important;
  max-height: var(--pcv2-card-height) !important;
  overflow: hidden !important;
}

article.pcv2-card,
article.pcv2-card > .pcv2-media,
article.pcv2-card > .pcv2-body,
article.pcv2-card .pcv2-content,
article.pcv2-card .pcv2-commerce,
article.pcv2-card .pcv2-actions {
  box-sizing: border-box !important;
  min-width: 0 !important;
}

/* One source of truth for the image stage. */
article.pcv2-card > .pcv2-media,
article.pcv2-card .pcv2-image-link {
  flex: 0 0 var(--pcv2-media-height) !important;
  height: var(--pcv2-media-height) !important;
  min-height: var(--pcv2-media-height) !important;
  max-height: var(--pcv2-media-height) !important;
}

/* The body owns all remaining card height. No competing hard-coded total. */
article.pcv2-card > .pcv2-body {
  display: flex !important;
  flex: 1 1 0 !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  padding: 12px !important;
}

article.pcv2-card .pcv2-content {
  flex: 0 0 124px !important;
  height: 124px !important;
  min-height: 124px !important;
  max-height: 124px !important;
}

article.pcv2-card .pcv2-commerce {
  display: flex !important;
  flex: 1 1 0 !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  padding-top: 4px !important;
}

/* Reserve the action block inside the card rather than letting content push it out. */
article.pcv2-card .pcv2-actions {
  display: grid !important;
  flex: 0 0 76px !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-template-rows: 36px 36px !important;
  gap: 6px 8px !important;
  width: 100% !important;
  height: 76px !important;
  min-height: 76px !important;
  max-height: 76px !important;
  margin-top: auto !important;
  padding: 0 !important;
  overflow: visible !important;
}

article.pcv2-card .pcv2-btn {
  min-width: 0 !important;
  width: 100% !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 10px !important;
  line-height: 1 !important;
}

article.pcv2-card .pcv2-buy {
  grid-column: 1 / -1 !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
}

/* Keep information rows compact and prevent them from stealing footer space. */
article.pcv2-card .pcv2-promo,
article.pcv2-card .pcv2-activity {
  flex-shrink: 0 !important;
}

article.pcv2-card .pcv2-delivery {
  flex: 0 0 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
}

article.pcv2-card .pcv2-stock-row {
  flex: 0 0 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  overflow: hidden !important;
}

/* Product rails reserve the complete card, shadow and bottom action area. */
.ps-product-slider-shell {
  min-height: calc(var(--pcv2-card-height, 600px) + 24px) !important;
  overflow: visible !important;
}

[data-product-slider],
.ps-product-slider-track,
.products-grid,
.products-row,
.product-grid,
.jumia-products-grid,
.ps-product-grid {
  min-height: 624px !important;
  padding-top: 6px !important;
  padding-bottom: 18px !important;
}

[data-product-slider] > article.pcv2-card,
.ps-product-slider-track > article.pcv2-card,
.products-grid > article.pcv2-card,
.product-grid > article.pcv2-card,
.jumia-products-grid > article.pcv2-card,
.ps-product-grid > article.pcv2-card {
  align-self: stretch !important;
}

/* Assistant must not obscure card actions near the bottom-right edge. */
@media (min-width: 992px) {
  .ps-ai-shop__launcher {
    right: 24px !important;
    bottom: 20px !important;
  }
}

@media (max-width: 767.98px) {
  article.pcv2-card {
    --pcv2-card-height: 526px;
    --pcv2-media-height: 190px;
  }

  article.pcv2-card > .pcv2-body {
    padding: 10px !important;
  }

  article.pcv2-card .pcv2-content {
    flex-basis: 118px !important;
    height: 118px !important;
    min-height: 118px !important;
    max-height: 118px !important;
  }

  article.pcv2-card .pcv2-actions {
    flex-basis: 70px !important;
    grid-template-rows: 33px 33px !important;
    height: 70px !important;
    min-height: 70px !important;
    max-height: 70px !important;
    gap: 4px 6px !important;
  }

  article.pcv2-card .pcv2-btn,
  article.pcv2-card .pcv2-buy {
    height: 33px !important;
    min-height: 33px !important;
    max-height: 33px !important;
  }

  .ps-product-slider-shell {
    min-height: 546px !important;
  }

  [data-product-slider],
  .ps-product-slider-track,
  .products-grid,
  .products-row,
  .product-grid,
  .jumia-products-grid,
  .ps-product-grid {
    min-height: 546px !important;
    padding-bottom: 14px !important;
  }
}
