/* STORE APP Patch 449 - Live catalog selector grid correction.
   Verified against rendered /product source: .mpb2b-catalog-layout contains
   .mpb2b-filter-panel + .mpb2b-catalog-results, and product cards are inside
   .mpb2b-product-grid.mpb2b-product-grid-catalog as .mpb2b-product-card.
*/

/* Desktop catalog page with left filter: exactly 2 layout columns: sidebar + results. */
body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-catalog-layout {
  display: grid !important;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) !important;
  gap: 24px !important;
  align-items: start !important;
  width: 100% !important;
}

body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-filter-panel,
body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-filter-panel,
body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-filter-panel {
  grid-column: 1 !important;
  width: 100% !important;
  max-width: 280px !important;
  min-width: 0 !important;
}

body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-catalog-results,
body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-catalog-results,
body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-catalog-results {
  grid-column: 2 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}

/* Actual live /product card grid. */
body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-product-grid.mpb2b-product-grid-catalog,
body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-product-grid.mpb2b-product-grid-catalog,
body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-product-grid.mpb2b-product-grid-catalog,
body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 18px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  align-items: stretch !important;
}

body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog > .mpb2b-product-card,
body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog > .mpb2b-product-card,
body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog > .mpb2b-product-card {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  grid-column: auto !important;
}

body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-product-media,
body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-product-media,
body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-product-media {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 220px !important;
  aspect-ratio: 4 / 3 !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: contain !important;
}

/* Category detail pages with side category menu also stay max 3 cards. */
body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 18px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

/* Remove product-card Quick Pay on list/catalog cards because it crowds the grid. */
body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-item-express,
body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-item-express,
body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog .mpb2b-item-express {
  display: none !important;
}

@media (max-width: 1199.98px) {
  body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
  body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
  body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-catalog-layout {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) !important;
    gap: 18px !important;
  }
  body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 767.98px) {
  body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
  body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-catalog-layout,
  body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-catalog-layout {
    display: block !important;
  }
  body.site-masterpalm #site-main .mpb2b-catalog-page .mpb2b-filter-panel,
  body.masterpalm-theme #site-main .mpb2b-catalog-page .mpb2b-filter-panel,
  body.masterpalm-store-dark #site-main .mpb2b-catalog-page .mpb2b-filter-panel {
    max-width: none !important;
    margin-bottom: 18px !important;
  }
  body.site-masterpalm #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.masterpalm-theme #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.masterpalm-store-dark #site-main .mpb2b-product-grid.mpb2b-product-grid-catalog,
  body.site-masterpalm #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-theme #site-main .mp-category-layout .mp-category-products-grid,
  body.masterpalm-store-dark #site-main .mp-category-layout .mp-category-products-grid {
    grid-template-columns: 1fr !important;
  }
}
