/* Only widen the main outer container, never header/footer or nested grids. */
body#category #wrapper > .container,
body#product #wrapper > .container {
  box-sizing: border-box;
  width: 100% !important;
  max-width: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

@media (max-width: 767.98px) {
  body#category #wrapper > .container,
  body#product #wrapper > .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  /* Classic rows use -15px gutters; match the narrower outer padding. */
  body#category #wrapper > .container > .row,
  body#product #wrapper > .container > .row {
    margin-left: -10px !important;
    margin-right: -10px !important;
  }
  body#category #wrapper > .container > .row > #content-wrapper,
  body#product #wrapper > .container > .row > #content-wrapper {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* All remaining rules concern only category grids. */
body#category .block-category,
body#category #left-column .block-categories {
  display: none !important;
}

body#category.sg-category-no-sidebar #left-column {
  display: none !important;
}

body#category.sg-category-no-sidebar #content-wrapper {
  width: 100% !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  left: auto !important;
  right: auto !important;
  float: none !important;
}

body#category #js-product-list .products {
  display: grid !important;
  grid-template-columns: repeat(var(--sg-cols-phone, 2), minmax(0, 1fr));
  gap: 3px !important;
  align-items: stretch;
  margin: 0 !important;
}

/* Bootstrap clearfix pseudo-elements must not become extra grid items. */
body#category #js-product-list .products::before,
body#category #js-product-list .products::after {
  display: none !important;
  content: none !important;
}

/* Classic versions use either .js-product wrappers or direct miniatures. */
body#category #js-product-list .products > .js-product,
body#category #js-product-list .products > .product,
body#category #js-product-list .products > .product-miniature {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  flex-basis: auto !important;
}

body#category #js-product-list .product-miniature,
body#category #js-product-list .thumbnail-container,
body#category #js-product-list .product-description {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body#category #js-product-list .product-thumbnail img {
  position: absolute !important;
  max-width: none !important;
  max-height: none !important;
  width: var(--sg-cover-width, 100%) !important;
  height: var(--sg-cover-height, 100%) !important;
  left: var(--sg-cover-left, 0%) !important;
  top: var(--sg-cover-top, 0%) !important;
  margin: 0 !important;
  object-fit: contain;
  transform: none !important;
}

body#category #js-product-list .product-thumbnail {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0 !important;
  margin: 0 !important;
  background: #fff;
}

body#category #js-product-list .product-thumbnail picture {
  display: contents;
}

body#category #js-product-list .thumbnail-container {
  height: 100% !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
}

body#category #js-product-list .product-miniature {
  height: 100%;
  margin-bottom: 0 !important;
}

body#category #js-product-list .thumbnail-top {
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
}

body#category #js-product-list .product-description {
  position: relative !important;
  height: auto !important;
  min-height: 70px;
  flex: 1 0 auto;
  padding: 6px 4px !important;
}

@media (min-width: 768px) {
  body#category #js-product-list .products {
    grid-template-columns: repeat(var(--sg-cols-tablet, 3), minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  body#category #js-product-list .products {
    grid-template-columns: repeat(var(--sg-cols-desktop, 4), minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  body#category #js-product-list .products {
    grid-template-columns: repeat(var(--sg-cols-wide, 5), minmax(0, 1fr));
  }
}

@media (max-width: 359.98px) {
  body#category #js-product-list .products {
    grid-template-columns: repeat(var(--sg-cols-tiny, 1), minmax(0, 1fr));
  }
}

/* Homepage carousels: keep this separate from category grids. */
body#index .products-carousel,
body#index .product-carousel,
body#index .owl-carousel,
body#index .swiper,
body#index .swiper-wrapper {
  --sg-carousel-gap: 3px;
}

body#index .products-carousel .product-miniature,
body#index .product-carousel .product-miniature,
body#index .owl-carousel .product-miniature,
body#index .swiper-slide .product-miniature {
  margin-left: 1.5px !important;
  margin-right: 1.5px !important;
}

body#index .products-carousel .product-thumbnail,
body#index .product-carousel .product-thumbnail,
body#index .owl-carousel .product-thumbnail,
body#index .swiper-slide .product-thumbnail {
  height: 250px !important;
  min-height: 250px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
}

body#index .products-carousel .product-thumbnail img,
body#index .product-carousel .product-thumbnail img,
body#index .owl-carousel .product-thumbnail img,
body#index .swiper-slide .product-thumbnail img {
  width: auto !important;
  height: 240px !important;
  max-width: 96% !important;
  max-height: 240px !important;
  object-fit: contain !important;
}

body#index .products-carousel .product-description,
body#index .product-carousel .product-description,
body#index .owl-carousel .product-description,
body#index .swiper-slide .product-description {
  min-height: 74px;
  padding: 6px 3px !important;
}

@media (max-width: 767.98px) {
  body#index .products-carousel .product-thumbnail,
  body#index .product-carousel .product-thumbnail,
  body#index .owl-carousel .product-thumbnail,
  body#index .swiper-slide .product-thumbnail {
    height: 190px !important;
    min-height: 190px !important;
  }
  body#index .products-carousel .product-thumbnail img,
  body#index .product-carousel .product-thumbnail img,
  body#index .owl-carousel .product-thumbnail img,
  body#index .swiper-slide .product-thumbnail img {
    height: 180px !important;
    max-height: 180px !important;
  }
}
