.wcpg-wrapper {
  display: grid;
  gap: 12px;
  --thumb-size: 64px;
  --gap: 8px;
  /* Aspect ratio for main media */
  --ratio-w: calc(1 * (var(--wcpg-aspect-ratio, 1/1)));
}

/* Layout variants */
.wcpg--thumbs-bottom {
  grid-template-areas:
    "main"
    "thumbs";
}

.wcpg--thumbs-left {
  grid-template-columns: minmax(56px, 120px) 1fr;
  grid-template-areas: "thumbs main";
  align-items: start;
}

.wcpg--thumbs-right {
  grid-template-columns: 1fr minmax(56px, 120px);
  grid-template-areas: "main thumbs";
  align-items: start;
}

.wcpg-main {
  grid-area: main;
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  aspect-ratio: var(--wcpg-aspect-ratio, 1 / 1);
  background: #f6f7f8;
  border-radius: 8px;
  overflow: hidden;
}

.wcpg-main .wcpg-main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Thumbnails */
.wcpg-thumbs-container {
  grid-area: thumbs;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.wcpg-thumbs {
  display: grid;
  gap: var(--gap);
  flex: 1;
}

.wcpg-scroll-arrow {
  width: 100%;
  height: 32px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.wcpg-scroll-arrow:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
}

.wcpg-scroll-arrow:active {
  background: rgba(0, 0, 0, 0.15);
}

.wcpg-scroll-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.wcpg-scroll-arrow svg {
  width: 20px;
  height: 20px;
}

/* Hide horizontal arrows on desktop (only show on mobile) */
.wcpg-scroll-left,
.wcpg-scroll-right {
  display: none;
}

/* Lightbox Styles */
.wcpg-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 999999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wcpg-lightbox.is-active {
  display: flex;
  opacity: 1;
}

.wcpg-lightbox-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  padding: 60px 80px;
}

.wcpg-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  animation: wcpgZoomIn 0.3s ease;
}

@keyframes wcpgZoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.wcpg-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  transition: all 0.2s ease;
  z-index: 10;
}

.wcpg-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(90deg);
}

.wcpg-lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s ease;
  z-index: 10;
}

.wcpg-lightbox-arrow:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.wcpg-lightbox-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.wcpg-lightbox-arrow-prev {
  left: 20px;
}

.wcpg-lightbox-arrow-next {
  right: 20px;
}

.wcpg-lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 500;
}

/* Mobile lightbox adjustments */
@media (max-width: 768px) {
  .wcpg-lightbox-content {
    padding: 40px 20px;
  }

  .wcpg-lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .wcpg-lightbox-arrow {
    width: 40px;
    height: 40px;
  }

  .wcpg-lightbox-arrow-prev {
    left: 10px;
  }

  .wcpg-lightbox-arrow-next {
    right: 10px;
  }

  .wcpg-lightbox-counter {
    bottom: 10px;
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* Zoom Styles */
.wcpg-main.has-zoom {
  cursor: zoom-in;
}

.wcpg-main.is-zooming {
  cursor: zoom-out;
}

.wcpg-zoom-lens {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.8);
  width: 100px;
  height: 100px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.wcpg-main.is-zooming .wcpg-zoom-lens {
  opacity: 1;
}

.wcpg-zoom-indicator {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 5;
}

.wcpg-main.has-zoom:hover .wcpg-zoom-indicator {
  opacity: 1;
}

/* Desktop zoom - image scales */
@media (min-width: 769px) {
  .wcpg-main.is-zooming .wcpg-main-img {
    transform-origin: var(--zoom-x, 50%) var(--zoom-y, 50%);
    transform: scale(2.5);
    transition: transform 0.1s ease-out;
  }
}

/* Mobile zoom indicator */
@media (max-width: 768px) {
  .wcpg-zoom-indicator {
    display: none;
  }
}

/* Skeleton Loader Styles */
.wcpg-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: wcpgShimmer 1.5s infinite linear;
  border-radius: 8px;
  z-index: 1;
}

@keyframes wcpgShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.wcpg-skeleton-main {
  border-radius: 8px;
}

.wcpg-skeleton-thumb {
  border-radius: 6px;
}

/* Hide skeleton once image is loaded */
.wcpg-main.has-skeleton .wcpg-main-img,
.wcpg-thumb.has-skeleton img {
  position: relative;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wcpg-main.has-skeleton.is-loaded .wcpg-main-img,
.wcpg-thumb.has-skeleton.is-loaded img {
  opacity: 1;
}

.wcpg-main.has-skeleton.is-loaded .wcpg-skeleton,
.wcpg-thumb.has-skeleton.is-loaded .wcpg-skeleton {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Bottom layout: horizontal scroll, shows 5 at a time */
.wcpg--thumbs-bottom .wcpg-thumbs {
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - (var(--gap) * 4)) / 5);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding-bottom: 4px;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.wcpg--thumbs-bottom .wcpg-thumbs::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

/* Left/Right layouts: vertical, shows 5 at a time with scroll */
.wcpg--thumbs-left .wcpg-thumbs,
.wcpg--thumbs-right .wcpg-thumbs {
  grid-auto-flow: row;
  grid-auto-rows: var(--thumb-size);
  grid-template-columns: 1fr;
  overflow-y: auto;
  max-height: calc(var(--thumb-size) * 5 + (var(--gap) * 4));
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.wcpg--thumbs-left .wcpg-thumbs::-webkit-scrollbar,
.wcpg--thumbs-right .wcpg-thumbs::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.wcpg-thumb {
  background: transparent;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  line-height: 0;
  scroll-snap-align: start;
  flex-shrink: 0;
}

.wcpg-thumb img {
  width: 100%;
  height: var(--thumb-size);
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.wcpg-thumb.is-active {
  border-color: #1e88e5;
  outline: none;
}

.wcpg-thumb:focus-visible {
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.35);
  outline: none;
}

/* Mobile tweaks */
@media (max-width: 768px) {
  .wcpg--thumbs-left,
  .wcpg--thumbs-right {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "thumbs";
  }

  /* Hide desktop vertical arrows on mobile */
  .wcpg-scroll-up,
  .wcpg-scroll-down {
    display: none !important;
  }

  /* Show mobile horizontal arrows */
  .wcpg-scroll-left,
  .wcpg-scroll-right {
    display: flex !important;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px !important;
    height: 48px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .wcpg-scroll-left {
    left: -4px;
  }

  .wcpg-scroll-right {
    right: -4px;
  }

  .wcpg-thumbs-container {
    position: relative;
    flex-direction: row !important;
  }

  /* Force horizontal layout for ALL thumbnail positions on mobile */
  .wcpg-thumbs,
  .wcpg--thumbs-left .wcpg-thumbs,
  .wcpg--thumbs-right .wcpg-thumbs,
  .wcpg--thumbs-bottom .wcpg-thumbs {
    display: grid !important;
    grid-auto-flow: column !important;
    grid-auto-columns: calc((100% - (var(--gap) * 2)) / 3) !important;
    grid-template-columns: none !important;
    grid-auto-rows: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory !important;
    scroll-behavior: smooth;
    /* Hide scrollbar on mobile */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .wcpg-thumbs::-webkit-scrollbar,
  .wcpg--thumbs-left .wcpg-thumbs::-webkit-scrollbar,
  .wcpg--thumbs-right .wcpg-thumbs::-webkit-scrollbar,
  .wcpg--thumbs-bottom .wcpg-thumbs::-webkit-scrollbar {
    display: none;
  }

  .wcpg-thumb {
    scroll-snap-align: start;
  }
}
