/* ==========================================================================
   Vertical Product Gallery – gallery.css
   Namespace: .vpg-*
   ========================================================================== */

/* ── Reset & base ──────────────────────────────────────────────────────────── */
.vpg-gallery-wrapper *,
.vpg-gallery-wrapper *::before,
.vpg-gallery-wrapper *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Wrapper layout ────────────────────────────────────────────────────────── */
/*
 * !important is required on flex-direction because Elementor wraps widget
 * content in a column flex container that would override row direction.
 */
.vpg-gallery-wrapper {
  display: flex !important;
  gap: 12px;
  width: 100%;
  position: relative;
  align-items: flex-start;
}

/* Thumbnails LEFT → main image on RIGHT */
.vpg-thumb-pos-left {
  flex-direction: row !important;
}

/* Thumbnails RIGHT → main image on LEFT */
.vpg-thumb-pos-right {
  flex-direction: row-reverse !important;
}

/* Thumbnails BOTTOM */
.vpg-thumb-pos-bottom {
  flex-direction: column !important;
}

/* ── Thumbnail strip ───────────────────────────────────────────────────────── */
.vpg-thumbnails {
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

/*
 * Vertical strip (left / right) – needs an explicit pixel height so Swiper's
 * vertical direction has a container size to work with.
 * height: 100% does not work when parent has no defined height.
 */
.vpg-thumb-pos-left  .vpg-thumbnails,
.vpg-thumb-pos-right .vpg-thumbnails {
  width: auto;
  height: 520px;
  max-height: 520px;
  overflow: hidden;
}

/* Horizontal strip (bottom) */
.vpg-thumb-pos-bottom .vpg-thumbnails {
  width: 100%;
  height: auto;
}

/* Force Swiper wrapper direction so it matches the strip orientation */
.vpg-thumb-pos-left  .vpg-thumbnails .swiper-wrapper,
.vpg-thumb-pos-right .vpg-thumbnails .swiper-wrapper {
  flex-direction: column !important;
  height: 100%;
}

.vpg-thumb-pos-bottom .vpg-thumbnails .swiper-wrapper {
  flex-direction: row !important;
}

/* ── Thumbnail item ────────────────────────────────────────────────────────── */
.vpg-thumb-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.25s ease, opacity 0.25s ease, transform 0.2s ease;
  opacity: 0.65;
  flex-shrink: 0;
  width: auto !important; /* Swiper sets inline width; we override with sizing classes */
}

.vpg-thumb-item:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.vpg-thumb-item.is-active {
  border-color: #0071a1;
  opacity: 1;
}

.vpg-thumb-item img {
  display: block;
  object-fit: cover;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Thumbnail size – controlled by Elementor slider (inline CSS).           ── */
/* Fallback default when no Elementor style is present yet (e.g. cold load). */
.vpg-thumb-item { width: 80px !important; height: 80px; }

/* ── Main image ────────────────────────────────────────────────────────────── */
.vpg-main-image {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  position: relative;
}

.vpg-main-image .swiper-wrapper {
  align-items: stretch;
}

.vpg-main-image .swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f5f5;
  border-radius: inherit;
  overflow: hidden;
}

.vpg-main-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 560px;
  transition: transform 0.4s ease;
  will-change: transform;
}

/* Zoom effect */
.vpg-gallery-wrapper[data-zoom="true"] .vpg-main-image img:hover {
  transform: scale(1.06);
  cursor: zoom-in;
}

/* ── Transition: Fade ──────────────────────────────────────────────────────── */
.vpg-gallery-wrapper[data-transition="fade"] .vpg-main-swiper {
  /* Swiper fade effect handles this via JS initialisation */
}

/* ── Swiper scrollbar ──────────────────────────────────────────────────────── */
.vpg-thumbnails .swiper-scrollbar {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}

.vpg-thumb-pos-left  .vpg-thumbnails .swiper-scrollbar,
.vpg-thumb-pos-right .vpg-thumbnails .swiper-scrollbar {
  position: absolute;
  right: -6px;
  top: 0;
  width: 4px;
  height: 100%;
}

.vpg-thumb-pos-bottom .vpg-thumbnails .swiper-scrollbar {
  position: relative;
  height: 4px;
  width: 100%;
  margin-top: 6px;
}

.vpg-thumbnails .swiper-scrollbar-drag {
  background: #0071a1;
  border-radius: 4px;
}

/* ── Lightbox ──────────────────────────────────────────────────────────────── */
.vpg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(6px);
}

.vpg-lightbox:not([hidden]) {
  opacity: 1;
}

.vpg-lightbox[hidden] {
  display: none;
}

.vpg-lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vpg-lightbox-content img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transition: transform 0.3s ease;
}

.vpg-lightbox-close {
  position: absolute;
  top: 20px;
  right: 28px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.vpg-lightbox-close:hover { background: rgba(255,255,255,0.25); }

.vpg-lightbox-prev,
.vpg-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0;
}
.vpg-lightbox-prev { left: 20px; }
.vpg-lightbox-next { right: 20px; }
.vpg-lightbox-prev:hover,
.vpg-lightbox-next:hover { background: rgba(255,255,255,0.25); }

/* ── Placeholder (editor / empty) ─────────────────────────────────────────── */
.vpg-placeholder,
.vpg-editor-notice {
  padding: 24px;
  background: #f0f0f0;
  border: 2px dashed #ccc;
  border-radius: 8px;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  width: 100%;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

/*
 * Only the "bottom" position collapses to a column stack on mobile.
 * "left" and "right" positions keep their side-by-side row layout on all
 * screen sizes so that thumbnails remain on the left / right as configured.
 */
@media (max-width: 767px) {

  /* ── Bottom position: stack vertically ── */
  .vpg-thumb-pos-bottom {
    flex-direction: column;
  }

  .vpg-thumb-pos-bottom .vpg-thumbnails {
    width: 100%;
    max-height: none;
  }

  .vpg-thumb-pos-bottom .vpg-thumbnails .swiper-wrapper {
    flex-direction: row;
  }

  .vpg-thumb-pos-bottom .vpg-thumbnails .swiper-scrollbar {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    height: 4px;
    margin-top: 6px;
  }

  /* ── Left / Right positions: keep row layout on mobile ── */

  /* Wrapper stays row – !important overrides any Elementor column flex */
  .vpg-thumb-pos-left  { flex-direction: row !important; }
  .vpg-thumb-pos-right { flex-direction: row-reverse !important; }

  /* Thumbnail strip stays vertical (column direction) */
  .vpg-thumb-pos-left  .vpg-thumbnails .swiper-wrapper,
  .vpg-thumb-pos-right .vpg-thumbnails .swiper-wrapper {
    flex-direction: column !important;
    height: 100%;
  }

  /* Explicit pixel height on mobile so vertical Swiper works */
  .vpg-thumb-pos-left  .vpg-thumbnails,
  .vpg-thumb-pos-right .vpg-thumbnails {
    width: auto;
    height: 300px !important;
    max-height: 300px;
    overflow: hidden;
  }

  /* Main image fills remaining flex space */
  .vpg-thumb-pos-left  .vpg-main-image,
  .vpg-thumb-pos-right .vpg-main-image {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* ── Shared mobile image height cap ── */
  .vpg-main-image img {
    max-height: 300px;
  }
}
