/* Listing / collection pages — DrMediCart polish aligned (no chrome overrides) */
:root {
  --listing-purple: var(--purple, #4939A5);
  --listing-purple-dark: var(--purple-dark, #351052);
  --listing-soft: var(--purple-soft, #eeecfb);
  --listing-ink: var(--ink, #292735);
  --listing-muted: #121212;
  --listing-line: var(--line, #E8E6EF);
  --listing-radius: var(--radius, 12px);
  --listing-shadow: var(--shadow, 0 8px 24px rgba(41, 39, 53, 0.08));
}

/* Collection hero */
.collection-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0;
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  min-height: clamp(180px, 20vw, 240px);
  height: clamp(180px, 20vw, 240px);
  background: linear-gradient(135deg, #351052 0%, #4939A5 55%, #6a5fe0 100%);
  box-shadow: var(--listing-shadow);
}

.collection-hero-media {
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.collection-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.collection-hero-copy {
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 28px;
  gap: 6px;
}

.collection-hero-copy p {
  margin: 0 !important;
  font-family: var(--font, Poppins, "Segoe UI", sans-serif);
  font-size: 11px !important;
  letter-spacing: 0.1em;
  font-weight: 700;
  line-height: 1.3 !important;
  opacity: 0.88;
  color: #fff !important;
}

.collection-hero-copy h1 {
  margin: 0 !important;
  font-family: var(--font, Poppins, "Segoe UI", sans-serif);
  font-size: clamp(22px, 2.6vw, 34px) !important;
  line-height: 1.15 !important;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff !important;
}

.collection-hero-copy span {
  font-size: 13px;
  line-height: 1.45;
  opacity: 0.9;
  max-width: 36ch;
}

/* Breadcrumbs + heading */
.breadcrumbs {
  min-height: 36px;
  height: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #121212;
  font-size: 12px;
  padding: 10px 0 4px;
}

.breadcrumbs a:hover { color: var(--listing-purple); }
.breadcrumbs b { color: var(--listing-ink); font-weight: 500; }

.collection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 14px;
  border-bottom: 1px solid var(--listing-line);
}

.collection-heading p {
  margin: 0 0 4px !important;
  font-size: 11px !important;
  letter-spacing: 0.08em;
  color: var(--listing-purple) !important;
  font-weight: 700;
  line-height: 1.3 !important;
}

.collection-heading h1 {
  font-size: 24px !important;
  line-height: 1.2 !important;
  margin: 0 0 4px !important;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--listing-ink) !important;
}

.result-count {
  color: #121212;
  font-size: 13px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #dce0e6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.view-btn {
  width: 36px;
  height: 34px;
  border: 0;
  background: transparent;
  color: #121212;
  cursor: pointer;
}

.view-btn.active {
  background: var(--listing-soft);
  color: var(--listing-purple);
}

.mobile-filter { display: none; }

/* Layout */
.collection-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0 36px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 96px;
  border: 1px solid var(--listing-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(41, 39, 53, 0.04);
  overflow: hidden;
}

.filter-top {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--listing-line);
  background: #f7f8fa;
}

.filter-top > b { font-size: 13px; font-weight: 650; }

.filter-top > button:not(.close-filters) {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--listing-purple);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.close-filters { display: none; }

.filter-group { border-bottom: 1px solid var(--listing-line); }

.filter-heading {
  height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border: 0;
  background: white;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--listing-ink);
}

.filter-heading span { font-size: 13px; color: #777; }

.filter-options { padding: 0 14px 12px; }
.filter-group.collapsed .filter-options { display: none; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  font-size: 13px;
  color: #3f4450;
  cursor: pointer;
  border-radius: 8px;
  padding: 0 4px;
}

.filter-option:hover { background: #f7f8fa; }

.filter-option input {
  accent-color: var(--listing-purple);
  width: 15px;
  height: 15px;
  margin: 0;
}

.filter-option small {
  margin-left: auto;
  font-size: 11px;
  color: #9a9da2;
}

.price-filter { padding-top: 2px; }

.price-values {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.price-filter input {
  width: 100%;
  accent-color: var(--listing-purple);
}

.price-filter > small {
  font-size: 11px;
  color: #92949a;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 12px 0;
}

.filter-chip {
  border: 1px solid #d8d3f5;
  background: var(--listing-soft);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--listing-purple-dark);
  font-size: 11px;
  font-weight: 500;
}

.show-results { display: none; }

/* Listing toolbar */
.listing-toolbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--listing-line);
  margin-bottom: 12px;
  color: #121212;
  font-size: 13px;
  padding-bottom: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-toggle {
  display: none;
  border: 1px solid #d7dadd;
  background: white;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  border: 1px solid #dce0e6;
  border-radius: 999px;
  padding: 0 12px 0 14px;
  background: #fff;
}

.sort-control select {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--listing-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 22px 9px 0;
  outline: 0;
  cursor: pointer;
}

.sort-control > b {
  position: absolute;
  right: 12px;
  pointer-events: none;
  font-size: 12px;
  color: #666;
}

.active-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.active-filter-row:empty { display: none; }

.active-filter-row button {
  border: 1px solid #d8d3f5;
  background: var(--listing-soft);
  padding: 6px 11px;
  color: var(--listing-purple-dark);
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
}

/* Product grid — match homepage cards */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.product-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.listing .product-card,
.product-grid .product-card {
  min-width: 0;
  border: 1px solid #e7e9ee;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(41, 39, 53, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.listing .product-card:hover,
.product-grid .product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--listing-shadow);
  border-color: #d7dbe6;
}

.product-card[hidden] { display: none !important; }

/* Match homepage DrMediCart cards (polish.css .product-image) */
.product-photo,
.listing .product-image,
.product-grid .product-image {
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafbfc;
  border-radius: 8px;
  padding: 12px;
  box-sizing: border-box;
}

.product-photo img,
.listing .product-image img,
.product-grid .product-image img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center center;
  transition: transform 0.35s ease;
}

.product-card:hover .product-photo img,
.product-card:hover .product-image img {
  transform: scale(1.04);
}

.listing .badge,
.product-grid .badge {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--listing-purple);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.wish,
.listing .heart {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 30px;
  height: 30px;
  border: 1px solid #e7e7e7;
  border-radius: 50%;
  background: #fff;
  color: #777;
  font-size: 16px;
  line-height: 28px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.wish:hover,
.wish.selected,
.listing .heart:hover,
.listing .heart.selected {
  color: #e11d48;
  border-color: #fecdd3;
  transform: scale(1.05);
}

/* Title/price inherit homepage polish.css .product-title / .price */

.product-price,
.listing .price,
.product-grid .price {
  min-height: 22px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.product-price strong,
.listing .price strong,
.product-grid .price strong {
  font-size: 13px;
  color: var(--listing-ink, #121212);
  font-weight: 650;
}

.product-price del,
.listing .price del,
.product-grid .price del {
  font-size: 11px;
  color: #333333;
}

.product-price .discount,
.listing .price .discount,
.product-grid .price .discount {
  font-size: 10px;
  color: #b42318;
  background: #fef3f2;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
}

/* Match homepage Add to cart button */
.listing .add-cart,
.listing .add-button,
.product-grid .add-cart,
.product-grid .add-button {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid !important;
  place-items: center;
  width: 100%;
  height: 36px;
  margin-top: 12px !important;
  padding: 0 10px;
  border: 1.5px solid rgb(54, 16, 82);
  border-radius: 8px;
  background: rgb(54, 16, 82);
  color: #d4ff4a !important;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.listing .add-cart::after,
.listing .add-button::after,
.product-grid .add-cart::after,
.product-grid .add-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.08) 42%,
    rgba(255, 255, 255, 0.38) 50%,
    rgba(255, 255, 255, 0.08) 58%,
    transparent 70%
  );
  transform: translateX(-130%);
  transition: transform 0.55s ease;
  pointer-events: none;
}

.listing .add-cart:hover,
.listing .add-button:hover,
.product-grid .add-cart:hover,
.product-grid .add-button:hover {
  background: rgb(42, 10, 68);
  border-color: rgb(42, 10, 68);
  color: #e8ff7a !important;
}

.listing .add-cart:hover::after,
.listing .add-button:hover::after,
.product-grid .add-cart:hover::after,
.product-grid .add-button:hover::after {
  transform: translateX(130%);
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: #121212;
  font-size: 14px;
}

.empty-state button {
  display: block;
  margin: 14px auto 0;
  border: 0;
  background: none;
  color: var(--listing-purple);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 0 10px;
}

.pagination button {
  min-width: 34px;
  height: 34px;
  border: 1px solid #e2e4e6;
  background: #fff;
  color: #555;
  font-size: 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--listing-purple);
  color: var(--listing-purple);
}

.pagination button.current {
  background: var(--listing-purple);
  border-color: var(--listing-purple);
  color: #fff;
}

.pagination button:disabled { color: #bbb; cursor: default; }
.pagination span { padding: 0 5px; color: #777; }

.page-note {
  text-align: center;
  color: #121212;
  font-size: 12px;
  margin: 8px 0 24px;
}

.listing-empty-copy {
  grid-column: 1 / -1;
  color: #121212;
  padding: 24px 0;
  margin: 0;
}

.shop-load-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  margin: 8px 0 4px;
  color: #121212;
  font-size: 13px;
}

.shop-load-sentinel[hidden],
.shop-load-actions[hidden],
.shop-load-cap[hidden] {
  display: none !important;
}

.shop-load-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d8d3f5;
  border-top-color: var(--listing-purple, #4939A5);
  border-radius: 50%;
  opacity: 0;
}

.shop-load-sentinel.is-loading .shop-load-spinner {
  opacity: 1;
  animation: shop-spin 0.7s linear infinite;
}

@keyframes shop-spin {
  to { transform: rotate(360deg); }
}

.shop-load-actions,
.shop-load-cap {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 12px 0 8px;
  padding: 18px 16px;
  border: 1px solid var(--listing-line, #E8E6EF);
  border-radius: 12px;
  background: #fafafa;
  text-align: center;
}

.shop-load-hint,
.shop-load-cap p {
  margin: 0;
  color: #121212;
  font-size: 13px;
  line-height: 1.45;
  max-width: 42ch;
}

.shop-load-more {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--listing-purple, #4939A5);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  padding: 11px 20px;
  cursor: pointer;
}

.shop-load-more:hover {
  background: var(--listing-purple-dark, #351052);
}

.shop-load-more:disabled {
  opacity: 0.7;
  cursor: wait;
}

.shop-load-more--secondary {
  background: #fff;
  color: var(--listing-purple, #4939A5);
  border: 1.5px solid var(--listing-purple, #4939A5);
}

.shop-load-more--secondary:hover {
  background: var(--listing-soft, #eeecfb);
}

.pagination {
  display: none !important;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  padding: 12px 18px;
  background: var(--listing-ink);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.25s;
  pointer-events: none;
  box-shadow: var(--listing-shadow);
}

.toast.show {
  opacity: 1;
  transform: none;
}

@media (max-width: 1100px) {
  .collection-layout {
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 16px;
  }

  .product-grid,
  .product-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .collection-hero {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .collection-hero-media { height: 140px; }

  .collection-hero-copy { padding: 16px 18px; }

  .collection-layout { display: block; padding-top: 10px; }

  /* Bottom sheet — must sit above sticky site-chrome (z-index 220) */
  .sidebar {
    position: fixed !important;
    z-index: 260 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: min(82vh, 640px);
    height: auto !important;
    margin: 0 !important;
    overflow: auto;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.18);
    transform: translate3d(0, 110%, 0);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.25s ease, visibility 0.25s;
  }

  .body-filter-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 250;
  }

  .body-filter-open .sidebar {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }

  .filter-top {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
  }

  .close-filters {
    display: block;
    border: 0;
    background: none;
    font-size: 24px;
    color: #555;
    cursor: pointer;
  }

  .show-results {
    display: block;
    position: sticky;
    bottom: 0;
    width: 100%;
    height: 46px;
    border: 0;
    background: var(--listing-purple);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-filter { display: none !important; }

  .filter-toggle {
    display: inline-flex !important;
    align-items: center;
    border: 1px solid #d8dbde;
    border-radius: 999px;
    background: #fff;
    color: #444;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 13px;
    cursor: pointer;
  }

  .view-toggle { display: none; }

  .listing-toolbar {
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .sort-control {
    max-width: 100%;
  }

  .collection-heading {
    padding: 4px 0 10px;
  }

  .product-grid,
  .product-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .product-photo,
  .listing .product-image {
    height: clamp(130px, 38vw, 180px);
  }

  .product-grid .product-card .title,
  .listing .product-card .title {
    font-size: 13px;
    line-height: 1.35;
  }
}

@media (max-width: 680px) {
  .collection-heading h1 { font-size: 20px !important; }
  .collection-hero-copy h1 { font-size: 22px !important; }
  .collection-hero { margin-top: 8px; border-radius: 12px; }
  .collection-heading { padding-bottom: 12px; }
}
