/* Two-column layout: left = thumbs, right = main image */
.woocommerce-product-gallery {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.woocommerce-product-gallery .flex-viewport {
  grid-column: 2;
  min-width: 0;
  height: var(--tbs-gallery-viewport-height, auto);
  max-height: var(--tbs-gallery-viewport-height, none);
}

.woocommerce div.product div.images {
  margin-bottom: 0 !important;
}
.woocommerce div.product div.images .flex-control-thumbs li {
  width: 100% !important;
}

.woocommerce .wp-block-woocommerce-product-image-gallery {
  max-width: 100% !important;
}
/* Thumbnails column */
.woocommerce-product-gallery .flex-control-thumbs {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: start;
  height: var(--tbs-gallery-viewport-height, auto);
  max-height: var(--tbs-gallery-viewport-height, none);
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  scrollbar-width: thin;
}

.woocommerce-product-gallery .flex-control-thumbs::-webkit-scrollbar { width: 6px; }
.woocommerce-product-gallery .flex-control-thumbs::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.25); border-radius: 999px; }

.woocommerce div.product div.images .flex-control-thumbs,
.woocommerce div.product div.images .flex-control-thumbs li {
  list-style: none !important;
  margin: 0;
  padding: 0;
}
.woocommerce div.product div.images .flex-control-thumbs {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Main wrapper sits on the right */
.woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
  grid-column: 2;
}

/* Thumb sizing */
.woocommerce-product-gallery .flex-control-thumbs li {
  width: 100%;
  flex: 0 0 auto;
  list-style: none;
}

.woocommerce-product-gallery .flex-control-thumbs img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid transparent;
}

/* Optional active highlight */
.woocommerce-product-gallery .flex-control-thumbs .flex-active img {
  border-color: #111;
}

.woocommerce-product-gallery .flex-direction-nav {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  z-index: 2;
  pointer-events: none;
}

.woocommerce-product-gallery .flex-direction-nav a {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  text-decoration: none;
  line-height: 1;
  pointer-events: auto;
  padding: 0.25rem 0.5rem;
}

.woocommerce-product-gallery .flex-direction-nav .flex-prev {
  left: 8px;
}

.woocommerce-product-gallery .flex-direction-nav .flex-next {
  right: 8px;
}

@media (max-width: 768px) {
  .woocommerce-product-gallery {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .woocommerce-product-gallery.woocommerce-product-gallery--without-images {
    display: block;
  }

  .woocommerce-product-gallery .flex-control-thumbs {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    max-height: none;
    gap: 0.5rem;
    list-style: none !important;
    padding: 0;
  }

  .woocommerce-product-gallery .flex-control-thumbs li {
    width: calc(25% - 0.5rem);
    flex: 0 0 calc(25% - 0.5rem);
    list-style: none !important;
    scroll-snap-align: unset;
  }

  .woocommerce-product-gallery .flex-control-thumbs img {
    width: 100%;
    height: auto;
  }

  .woocommerce-product-gallery .flex-direction-nav .flex-prev {
    left: 4px;
  }

  .woocommerce-product-gallery .flex-direction-nav .flex-next {
    right: 4px;
  }

  .woocommerce-product-gallery .flex-direction-nav a {
    padding: 0.25rem;
  }
}

.woocommerce-product-gallery .flex-control-thumbs li {
  display: block;
}

.woocommerce-product-gallery .flex-control-thumbs li::marker {
  content: "";
}

.woocommerce-product-gallery .flex-control-thumbs li::before,
.woocommerce div.product div.images .flex-control-thumbs li::before {
  display: none !important;
  content: none !important;
}
