/**
 * Storefront Product Cards — single source of truth
 * Equal height · no overflow · Amazon / Shopify style
 */

:root {
  --pc-gap: 24px;
  --pc-radius: 20px;
  --pc-img-h: 220px;
  --pc-title-h: 48px;
  --pc-desc-h: 40px;
  --pc-qty-w: 120px;
  --pc-action-h: 46px;
  --pc-pad: 14px;
  --pc-border: rgba(15, 23, 42, 0.08);
  --pc-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --pc-shadow-hover: 0 16px 36px rgba(15, 23, 42, 0.12);
  --pc-price: #dc2626;
  --pc-bg: #ffffff;
  --pc-img-bg: #f8fafc;
  --pc-btn: #2563eb;
}

html[data-theme="dark"] {
  --pc-border: rgba(148, 163, 184, 0.18);
  --pc-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --pc-shadow-hover: 0 16px 36px rgba(0, 0, 0, 0.45);
  --pc-bg: #1e293b;
  --pc-img-bg: #0f172a;
  --pc-price: #f87171;
  --pc-btn: #3b82f6;
}

/* --------------------------------------------------------------------------
   Grid — 2 / 3 / 4 / 5 · gap 24px
   -------------------------------------------------------------------------- */
.products-grid,
.storefront-products-grid,
.pc-grid,
.premium-product-grid:not(.row) {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--pc-gap) !important;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.premium-product-grid.row {
  display: flex !important;
  flex-wrap: wrap;
  --bs-gutter-x: var(--pc-gap);
  --bs-gutter-y: var(--pc-gap);
}

.premium-product-grid > .col,
.premium-product-grid > [class*="col-"],
.category-page > .col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

@media (min-width: 576px) {
  .products-grid,
  .storefront-products-grid,
  .pc-grid,
  .premium-product-grid:not(.row) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .products-grid,
  .storefront-products-grid,
  .pc-grid,
  .premium-product-grid:not(.row) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .products-grid,
  .storefront-products-grid,
  .pc-grid,
  .premium-product-grid:not(.row) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .products-grid,
  .storefront-products-grid,
  .pc-grid,
  .premium-product-grid:not(.row) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  /* Sidebar shop: keep cards wide enough for qty + Add until ultra-wide */
  .storefront-grid--sidebar .products-grid,
  .storefront-grid--sidebar .pc-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 1600px) {
  .storefront-grid--sidebar .products-grid,
  .storefront-grid--sidebar .pc-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
}

/* --------------------------------------------------------------------------
   Card shell
   -------------------------------------------------------------------------- */
.product-card,
.siva-card.product-card,
.pc-card,
.siva-card {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  background: var(--pc-bg) !important;
  border: 1px solid var(--pc-border) !important;
  border-radius: var(--pc-radius) !important;
  overflow: hidden;
  box-sizing: border-box !important;
  box-shadow: var(--pc-shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  position: relative;
}

@media (hover: hover) {
  .product-card:hover,
  .siva-card:hover,
  .pc-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: var(--pc-shadow-hover) !important;
    border-color: rgba(37, 99, 235, 0.28) !important;
  }
}

/* --------------------------------------------------------------------------
   Media — fixed height
   -------------------------------------------------------------------------- */
.product-card .product-image-container,
.product-card .siva-media,
.product-card .product-media,
.product-card .pc-media,
.siva-card .siva-media,
.siva-card .product-media,
.siva-card .pc-media {
  position: relative;
  flex: 0 0 var(--pc-img-h) !important;
  height: var(--pc-img-h) !important;
  min-height: var(--pc-img-h) !important;
  max-height: var(--pc-img-h) !important;
  width: 100%;
  max-width: 100%;
  background: var(--pc-img-bg) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px !important;
  margin: 0 !important;
  aspect-ratio: auto !important;
  box-sizing: border-box;
}

.product-card .product-image-box,
.product-card .no-image-box,
.siva-card .product-image-box {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border-radius: 0 !important;
}

.product-card .product-image,
.product-card .siva-media img,
.product-card .product-image-box img,
.siva-card .siva-media img,
.siva-card .product-image {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain !important;
  object-position: center;
  padding: 0 !important;
  transition: transform 0.3s ease;
}

@media (hover: hover) {
  .product-card:hover .product-image,
  .product-card:hover .siva-media img,
  .siva-card:hover .siva-media img {
    transform: scale(1.05) !important;
  }
}

.product-card .pc-stock-badge,
.product-card .siva-badge,
.siva-card .siva-badge {
  position: absolute !important;
  top: 10px;
  left: 10px;
  z-index: 3;
  margin: 0 !important;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  max-width: calc(100% - 56px);
}

.product-card .btn-wishlist,
.product-card .siva-wishlist,
.product-card .wishlist-heart,
.siva-card .siva-wishlist,
.siva-card .btn-wishlist {
  position: absolute !important;
  top: 10px;
  right: 10px;
  z-index: 4;
}

.product-card .trending-sold-badge {
  top: auto !important;
  bottom: 10px !important;
  left: 10px !important;
  z-index: 2;
  max-width: calc(100% - 20px);
}

/* --------------------------------------------------------------------------
   Body
   -------------------------------------------------------------------------- */
.product-card > .card-body,
.product-card .card-body,
.product-card .siva-card-body,
.product-card .pc-body,
.siva-card .siva-card-body,
.siva-card .pc-body {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: var(--pc-pad) !important;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: visible;
  box-sizing: border-box !important;
  background: transparent !important;
}

.product-card .card-title,
.product-card .siva-name,
.product-card .pc-title,
.product-card .product-title,
.siva-card .siva-name,
.siva-card .pc-title,
.product-card h5.card-title,
.product-card h3.siva-name {
  height: var(--pc-title-h) !important;
  min-height: var(--pc-title-h) !important;
  max-height: var(--pc-title-h) !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: clamp(0.8rem, 1.4vw, 0.92rem) !important;
  font-weight: 650 !important;
  line-height: 1.3 !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
  word-break: break-word;
  width: 100%;
  flex-shrink: 0;
}

.product-card .card-text,
.product-card .product-desc,
.product-card .pc-desc,
.siva-card .pc-desc {
  height: var(--pc-desc-h) !important;
  min-height: var(--pc-desc-h) !important;
  max-height: var(--pc-desc-h) !important;
  margin: 0 !important;
  font-size: 0.78rem !important;
  line-height: 1.35 !important;
  color: #64748b !important;
  overflow: hidden;
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  width: 100%;
}

html[data-theme="dark"] .product-card .card-text,
html[data-theme="dark"] .product-card .product-desc,
html[data-theme="dark"] .product-card .pc-desc {
  color: #94a3b8 !important;
}

.product-card .pc-meta,
.product-card .siva-price,
.product-card .price-stock-row,
.siva-card .siva-price,
.siva-card .pc-meta {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 6px;
  min-height: 28px;
  margin: 0 !important;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
}

.product-card .pc-price,
.product-card .price-container,
.product-card .siva-price strong,
.product-card .product-price,
.siva-card .siva-price strong,
.siva-card .pc-price {
  font-weight: 700 !important;
  font-size: clamp(0.85rem, 1.5vw, 1.02rem) !important;
  color: var(--pc-price) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.product-card .pc-stock,
.product-card .siva-price small,
.product-card .stock-label,
.siva-card .siva-price small,
.siva-card .pc-stock {
  font-size: 0.68rem !important;
  color: #64748b !important;
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Actions — Amazon / Shopify stacked: [-][qty][+] then full-width Add to Cart
   -------------------------------------------------------------------------- */
.product-card .add-to-cart-form,
.siva-card .add-to-cart-form {
  display: flex !important;
  flex-direction: column !important;
  margin-top: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  flex-shrink: 0;
  padding-top: 4px !important;
}

.product-card .actions,
.product-card .pc-actions,
.product-card .button-group,
.product-card .siva-actions,
.product-card .product-actions-row,
.siva-card .actions,
.siva-card .siva-actions,
.siva-card .pc-actions,
.siva-card .product-actions-row {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-top: auto !important;
  flex-shrink: 0;
  position: static !important;
  box-sizing: border-box !important;
}

/* View + Login (no qty) stay side-by-side */
.product-card .actions:not(:has(.quantity-group)),
.product-card .pc-actions:not(:has(.quantity-group)),
.product-card .button-group:not(:has(.quantity-group)),
.siva-card .actions:not(:has(.quantity-group)),
.siva-card .pc-actions:not(:has(.quantity-group)) {
  flex-direction: row !important;
  align-items: center !important;
}

.product-card .quantity-group,
.siva-card .quantity-group {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: var(--pc-action-h) !important;
  flex: 0 0 auto !important;
  border: 1px solid var(--pc-border) !important;
  border-radius: 12px !important;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.04);
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

html[data-theme="dark"] .product-card .quantity-group,
html[data-theme="dark"] .siva-card .quantity-group {
  background: rgba(255, 255, 255, 0.06);
}

.product-card .quantity-group .btn,
.product-card .quantity-decrease,
.product-card .quantity-increase,
.siva-card .quantity-group .btn,
.siva-card .quantity-decrease,
.siva-card .quantity-increase {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px !important;
  transform: none !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: inherit !important;
  line-height: 1 !important;
  cursor: pointer;
  user-select: none;
}

.product-card .quantity-group .btn:hover,
.product-card .quantity-decrease:hover,
.product-card .quantity-increase:hover,
.siva-card .quantity-group .btn:hover {
  background: rgba(37, 99, 235, 0.08) !important;
}

.product-card .quantity-input,
.siva-card .quantity-input {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 56px !important;
  max-width: none !important;
  height: 100% !important;
  border: 0 !important;
  border-left: 1px solid var(--pc-border) !important;
  border-right: 1px solid var(--pc-border) !important;
  background: transparent !important;
  text-align: center !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
  padding: 0 8px !important;
  box-shadow: none !important;
  color: inherit !important;
  -moz-appearance: textfield;
  appearance: textfield;
  outline: none !important;
}

.product-card .quantity-input:focus,
.siva-card .quantity-input:focus {
  background: rgba(37, 99, 235, 0.06) !important;
}

.product-card .quantity-input::-webkit-outer-spin-button,
.product-card .quantity-input::-webkit-inner-spin-button,
.siva-card .quantity-input::-webkit-outer-spin-button,
.siva-card .quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.product-card .btn-add-to-cart,
.siva-card .btn-add-to-cart {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  height: var(--pc-action-h) !important;
  min-height: var(--pc-action-h) !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 0 0 auto !important;
  padding: 0 14px !important;
  border: 0 !important;
  border-radius: 12px !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  background: var(--pc-btn) !important;
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28) !important;
  transform: none !important;
  position: static !important;
  box-sizing: border-box !important;
  cursor: pointer;
  transition: filter 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease !important;
}

.product-card .btn-add-to-cart i,
.product-card .btn-add-to-cart .bi,
.siva-card .btn-add-to-cart i,
.siva-card .btn-add-to-cart .bi {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-card .btn-add-to-cart span,
.siva-card .btn-add-to-cart span {
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: visible;
}

.product-card .btn-add-to-cart .btn-label-short,
.siva-card .btn-add-to-cart .btn-label-short {
  display: none !important;
}

.product-card .btn-add-to-cart .btn-label-full,
.siva-card .btn-add-to-cart .btn-label-full {
  display: inline !important;
}

@media (hover: hover) {
  .product-card .btn-add-to-cart:hover,
  .siva-card .btn-add-to-cart:hover {
    filter: brightness(1.06);
    transform: translateY(-1px) !important;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35) !important;
    color: #fff !important;
  }
}

.product-card .btn-add-to-cart:disabled,
.siva-card .btn-add-to-cart:disabled {
  opacity: 0.75;
  cursor: wait;
  transform: none !important;
}

.product-card .button-group > .btn,
.product-card .pc-actions > .btn,
.product-card .pc-actions > a.btn,
.product-card .actions > .btn,
.product-card .actions > a.btn {
  min-width: 0 !important;
  flex: 1 1 0% !important;
  height: var(--pc-action-h) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.5rem;
  box-sizing: border-box;
}

.product-card .pc-actions form,
.product-card .button-group form,
.product-card .actions form {
  display: flex;
  flex: 1 1 0%;
  min-width: 0;
  margin: 0;
}

.product-card .pc-actions form .btn,
.product-card .button-group form .btn,
.product-card .actions form .btn {
  width: 100%;
  height: var(--pc-action-h);
  min-width: 0;
}

.product-card > a.btn,
.product-card .pc-body > a.btn,
.siva-card .pc-body > a.btn {
  margin-top: auto;
  width: 100%;
  max-width: 100%;
  height: var(--pc-action-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 10px;
}

.product-card .alert {
  margin: 0 !important;
  margin-top: auto !important;
  width: 100%;
  font-size: 0.8rem;
  border-radius: 10px;
}

.product-card .pc-extra { display: none; }

/* --------------------------------------------------------------------------
   Breakpoints — image / action stacking
   -------------------------------------------------------------------------- */
@media (max-width: 1399.98px) {
  :root { --pc-img-h: 200px; }
}

@media (max-width: 1199.98px) {
  :root { --pc-img-h: 190px; --pc-pad: 12px; }
}

@media (max-width: 991.98px) {
  :root { --pc-img-h: 180px; --pc-title-h: 44px; }
}

@media (max-width: 767.98px) {
  :root {
    --pc-img-h: 160px;
    --pc-gap: 12px;
    --pc-title-h: 42px;
    --pc-desc-h: 0px;
    --pc-pad: 10px;
    --pc-action-h: 46px;
  }

  .product-card .card-text,
  .product-card .product-desc,
  .product-card .pc-desc,
  .siva-card .pc-desc {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
  }

  .product-card .btn-wishlist,
  .product-card .siva-wishlist,
  .siva-card .siva-wishlist {
    width: 34px !important;
    height: 34px !important;
    top: 6px;
    right: 6px;
  }
}

@media (max-width: 479.98px) {
  :root { --pc-img-h: 150px; --pc-gap: 10px; --pc-action-h: 44px; }
}

@media (max-width: 374.98px) {
  :root { --pc-img-h: 140px; --pc-gap: 8px; --pc-pad: 8px; }

  .product-card .btn-add-to-cart,
  .siva-card .btn-add-to-cart {
    font-size: 0.82rem !important;
  }
}

@media (min-width: 1600px) {
  :root { --pc-img-h: 240px; }
}

@media (min-width: 1920px) {
  :root { --pc-img-h: 250px; }
}

@media (hover: none) {
  .product-card:hover,
  .siva-card:hover {
    transform: none !important;
  }
  .product-card:hover .product-image,
  .siva-card:hover .siva-media img {
    transform: none !important;
  }
}

.product-card img,
.siva-card img {
  max-width: 100%;
}
