/* Al Rayan Mobile V8 — product listing card presentation only.
   Loaded after site.css, so the original design and all non-product pages stay unchanged.
   This does not change category tiles, detail gallery, admin, checkout, or maintenance. */

/* Avoid stretching a short card to the height of an adjacent card. */
.products-grid {
  align-items: start;
}
.products-grid .product-card {
  min-width: 0;
}
.products-grid .product-card > a:first-child {
  display: block;
  line-height: 0;
}
/* A square image frame uses the full card width on phones, while contain prevents cropping. */
.products-grid .product-card .product-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  padding: 6px;
  background: #fff;
}
/* Keep the title, code, price and action in a compact, readable block. */
.products-grid .product-card .body {
  flex: 0 0 auto;
  padding: 10px 11px 12px;
  gap: 5px;
}
.products-grid .product-card .product-name {
  min-height: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.products-grid .product-card .card-code {
  display: block;
  line-height: 1.35;
}
.products-grid .product-card .price {
  line-height: 1.4;
}
.products-grid .product-card .stock {
  line-height: 1.4;
}
.products-grid .product-card .btn {
  margin-top: 5px;
  min-height: 34px;
}

/* A sole product is centered without filling the entire row. */
.products-grid > .product-card:only-child {
  grid-column: 1 / -1;
  justify-self: center;
  width: min(100%, 230px);
}

@media (max-width: 700px) {
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .products-grid .product-card .product-image {
    padding: 4px;
  }
  .products-grid .product-card .body {
    padding: 8px 9px 11px;
    gap: 4px;
  }
  .products-grid .product-card .product-name {
    font-size: 12px;
  }
  .products-grid .product-card .price {
    font-size: 17px;
  }
  .products-grid .product-card .btn {
    font-size: 11px;
    padding: 8px 5px;
  }
  .products-grid > .product-card:only-child {
    width: min(100%, 192px);
  }
}
