/**
 * Product page gallery — main image + thumbnail column
 */

.stedrino-pdp__media {
  min-width: 0;
}

.stedrino-pdp-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 0.75rem;
  align-items: start;
  background: #f3f5f8;
  border-radius: var(--st-radius-sm);
  padding: 0.75rem;
  overflow: hidden;
}

.stedrino-pdp-gallery--placeholder .stedrino-pdp-gallery__main {
  grid-column: 1 / -1;
}

.stedrino-pdp-gallery__main {
  position: relative;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  min-height: 280px;
}

.stedrino-pdp-gallery__zoom {
  display: block;
  width: 100%;
  height: 100%;
  line-height: 0;
}

.stedrino-pdp-gallery__image,
.stedrino-pdp-gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #fff;
}

.stedrino-pdp-gallery__thumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: min(520px, 70vh);
  overflow-y: auto;
  scrollbar-width: thin;
}

.stedrino-pdp-gallery__thumb {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stedrino-pdp-gallery__thumb-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.stedrino-pdp-gallery__thumb-btn img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
}

.stedrino-pdp-gallery__thumb.is-active .stedrino-pdp-gallery__thumb-btn,
.stedrino-pdp-gallery__thumb-btn:hover {
  border-color: var(--st-pink);
  box-shadow: 0 0 0 2px rgba(217, 35, 135, 0.15);
}

/* Hide broken default WC flexslider output if any plugin re-adds it */
.stedrino-pdp__media .flex-control-thumbs,
.stedrino-pdp__media .flex-viewport + ol,
.stedrino-pdp__media ol.flex-control-nav {
  display: none !important;
}

.stedrino-pdp__media .woocommerce-product-gallery__wrapper:not(.stedrino-pdp-gallery *) {
  display: none;
}

@media (max-width: 768px) {
  .stedrino-pdp-gallery {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .stedrino-pdp-gallery__thumbs {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    order: 2;
  }

  .stedrino-pdp-gallery__thumb {
    flex: 0 0 72px;
  }

  .stedrino-pdp-gallery__thumb-btn img {
    height: 72px;
    width: 72px;
  }

  .stedrino-pdp-gallery__main {
    min-height: min(72vw, 420px);
  }
}

[dir="rtl"] .stedrino-pdp-gallery {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
}

[dir="rtl"] .stedrino-pdp-gallery__main,
[dir="rtl"] .stedrino-pdp-gallery__thumbs {
  grid-column: auto;
}

[dir="rtl"] .stedrino-pdp-gallery__thumbs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

[dir="rtl"] .stedrino-pdp-gallery__thumb {
  flex: 0 0 72px;
}

[dir="rtl"] .stedrino-pdp-gallery__thumb-btn img {
  width: 72px;
  height: 72px;
}

@media (max-width: 768px) {
  [dir="rtl"] .stedrino-pdp-gallery {
    grid-template-columns: 1fr;
  }

  [dir="rtl"] .stedrino-pdp-gallery__main,
  [dir="rtl"] .stedrino-pdp-gallery__thumbs {
    grid-column: auto;
  }
}
