/* ============================================================
   GoGiftings V27 — Mobile Listing Grid Fix
   Fixes uneven card heights, misaligned buttons, tag overflow,
   and broken 2-col grid layout on mobile viewports.
   ============================================================ */

/* ─── 1. LISTING LAYOUT — full-width on mobile, no sidebar gap ─ */
@media (max-width: 900px) {
  body.gg-listing-page .listing-layout {
    display: block !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  body.gg-listing-page .sidebar {
    margin-bottom: 12px !important;
  }
}

/* ─── 2. GRID — clean 2-col on all mobile/tablet ─────────────── */
@media (max-width: 900px) {
  .gg-unified-grid,
  .listing-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
}

@media (max-width: 400px) {
  .gg-unified-grid,
  .listing-grid {
    gap: 8px !important;
  }
}

/* ─── 3. CARD — equal height via flex column ─────────────────── */
.gg-unified-card,
.listing-grid .product-card {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;         /* fill grid row */
  min-height: 0 !important;
  box-sizing: border-box !important;
  padding: 8px !important;
  border-radius: 18px !important;
  background: #fff !important;
  border: 1px solid #eedaea !important;
  box-shadow: 0 4px 14px rgba(107,32,96,.07) !important;
  overflow: hidden !important;
  position: relative !important;
}

/* ─── 4. THUMB WRAP — locked square, never collapses ─────────── */
.gg-unified-card .thumb-wrap,
.listing-grid .product-card .thumb-wrap {
  position: relative !important;
  width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  background: #fff7fb !important;
  border: 1px solid #f3e2ef !important;
  flex-shrink: 0 !important;        /* never shrink the image */
}

/* ─── 5. IMAGE — fill the square completely ──────────────────── */
.gg-unified-card .product-thumb,
.listing-grid .product-card .product-thumb {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}

.gg-unified-card .gg-unified-img,
.listing-grid .product-card img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
  transition: transform .35s ease !important;
}

/* ─── 6. DELIVERY TAG — fixed to bottom-right of image ──────── */
.gg-unified-card .gg-tag {
  position: absolute !important;
  bottom: 8px !important;
  right: 8px !important;
  top: auto !important;
  left: auto !important;
  max-width: calc(100% - 16px) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-size: 8.5px !important;
  font-weight: 900 !important;
  padding: 4px 7px !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: #f62780 !important;
  border: 1px solid #fad4e8 !important;
  box-shadow: 0 2px 8px rgba(246,39,128,.15) !important;
  z-index: 4 !important;
  letter-spacing: .02em !important;
  text-transform: uppercase !important;
  line-height: 1.2 !important;
}

/* ─── 7. CARD BODY — flex column, pushes actions to bottom ──── */
.gg-unified-card .product-card-body,
.listing-grid .product-card .product-card-body {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;              /* grow to fill remaining height */
  padding: 8px 4px 4px !important;
  gap: 0 !important;
}

/* ─── 8. PRODUCT NAME ────────────────────────────────────────── */
.gg-unified-card h4,
.listing-grid .product-card h4 {
  font-size: 12.5px !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  color: #1a1625 !important;
  margin: 0 0 6px !important;
  /* clamp to 2 lines — keeps all cards same height */
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  min-height: 0 !important;
}

.gg-unified-card h4 a,
.listing-grid .product-card h4 a {
  color: inherit !important;
  text-decoration: none !important;
}

/* ─── 9. PRICE ROW ───────────────────────────────────────────── */
.gg-unified-card .price,
.listing-grid .product-card .price {
  font-size: 15px !important;
  font-weight: 900 !important;
  color: #f62780 !important;
  display: flex !important;
  align-items: baseline !important;
  gap: 4px !important;
  margin-bottom: 4px !important;
  flex-wrap: nowrap !important;
}

.gg-unified-card .price .currency-text,
.listing-grid .product-card .price .currency-text {
  font-size: 11px !important;
  font-weight: 800 !important;
  color: #8c7893 !important;
}

/* ─── 10. DELIVERY META LINE ─────────────────────────────────── */
.gg-unified-card .meta,
.listing-grid .product-card .meta {
  font-size: 10.5px !important;
  color: #179a52 !important;
  font-weight: 700 !important;
  margin-bottom: 8px !important;
  line-height: 1.3 !important;
  /* clamp to 1 line */
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Remove the bullet pseudo-element on mobile — saves space */
.gg-unified-card .meta::before,
.listing-grid .product-card .meta::before {
  content: '● ' !important;
  font-size: 8px !important;
  vertical-align: 1px !important;
}

/* ─── 11. ACTION BUTTONS — push to bottom, full width ───────── */
.gg-unified-card .gg-card-actions,
.listing-grid .product-card .gg-card-actions {
  margin-top: auto !important;     /* stick to bottom of card */
  display: grid !important;
  grid-template-columns: 1fr 1.4fr !important;
  gap: 6px !important;
  align-items: stretch !important;
}

/* View button */
.gg-unified-card .gg-view-btn,
.listing-grid .product-card .gg-view-btn {
  height: 34px !important;
  min-height: 34px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px !important;
  background: #fff0f6 !important;
  color: #f62780 !important;
  border: 1.5px solid #fad4e8 !important;
  font-weight: 900 !important;
  font-size: 11px !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  transition: background .15s !important;
}
.gg-unified-card .gg-view-btn:hover {
  background: #ffe0ef !important;
}

/* Add to Cart button */
.gg-unified-card .quick-add,
.gg-unified-card .gg-add-btn,
.listing-grid .product-card .quick-add,
.listing-grid .product-card .gg-add-btn {
  height: 34px !important;
  min-height: 34px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #f62780, #5a1a93) !important;
  color: #fff !important;
  border: 0 !important;
  font-weight: 900 !important;
  font-size: 11px !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  transition: opacity .15s !important;
}
.gg-unified-card .quick-add:hover {
  opacity: .88 !important;
}

/* ─── 12. SORTBAR — tighter on mobile ───────────────────────── */
@media (max-width: 600px) {
  .sortbar {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px 16px !important;
    border-radius: 16px !important;
    margin-bottom: 12px !important;
  }
  .sortbar h1 {
    font-size: 22px !important;
    margin: 0 !important;
  }
  .sortbar p {
    font-size: 12px !important;
    margin: 2px 0 0 !important;
  }
  .sort-select {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ─── 13. CONTAINER PADDING ON MOBILE ────────────────────────── */
@media (max-width: 600px) {
  .listing-layout > section,
  .listing-layout > .section {
    padding: 0 !important;
  }
  /* Ensure grid doesn't overflow viewport */
  .gg-unified-grid,
  .listing-grid {
    max-width: 100% !important;
    overflow: hidden !important;
  }
}

/* ─── 14. CARD HOVER — subtler on touch devices ──────────────── */
@media (hover: none) {
  .gg-unified-card:hover {
    transform: none !important;
    box-shadow: 0 4px 14px rgba(107,32,96,.07) !important;
  }
  .gg-unified-card .gg-unified-img {
    transform: none !important;
  }
}


/* ============================================================
   V28 PATCH — Button centering + gap fixes for product cards
   ============================================================ */

/* ── Card action buttons: always centered ── */
.gg-unified-card .gg-card-actions,
.listing-grid .product-card .gg-card-actions {
  display: grid !important;
  grid-template-columns: 1fr 1.5fr !important;
  gap: 7px !important;
  margin-top: auto !important;
  padding-top: 8px !important;
  align-items: stretch !important;
}

.gg-unified-card .gg-view-btn,
.gg-unified-card .quick-add,
.gg-unified-card .gg-add-btn,
.listing-grid .product-card .gg-view-btn,
.listing-grid .product-card .quick-add,
.listing-grid .product-card .gg-add-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ── Remove unwanted gaps between cards ── */
.gg-unified-grid,
.listing-grid {
  row-gap: 14px !important;
  column-gap: 12px !important;
}

/* ── Desktop grid: keep 3-col ── */
@media (min-width: 901px) {
  .gg-unified-grid,
  .listing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 18px !important;
  }
}

/* ── Card: zero padding bottom to avoid gap under button ── */
.gg-unified-card,
.listing-grid .product-card {
  padding-bottom: 10px !important;
}

/* ── Product card body: no orphan gap below button ── */
.gg-unified-card .product-card-body,
.listing-grid .product-card .product-card-body {
  padding-bottom: 0 !important;
}
