/* ==========================================================================
   AZ PRODUCT GALLERY FRONTEND CSS
   ========================================================================== */

:root {
  --az-active-border: #ea580c;
  --az-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.az-product-gallery-container {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.az-product-gallery-container *,
.az-product-gallery-container *::before,
.az-product-gallery-container *::after {
  box-sizing: border-box;
}

.az-product-gallery-wrapper {
  display: flex;
  position: relative;
  width: 100%;
}

/* ==========================================
   LAYOUT MODES
   ========================================== */

/* 1. Horizontal Bottom (Thumbs under Main) */
.az-layout-horizontal-bottom .az-product-gallery-wrapper {
  flex-direction: column;
  gap: 15px;
}
.az-layout-horizontal-bottom .az-product-gallery-main {
  width: 100%;
  order: 1;
}
.az-layout-horizontal-bottom .az-product-gallery-thumbs {
  width: 100%;
  order: 2;
}

/* 2. Horizontal Top (Thumbs above Main) */
.az-layout-horizontal-top .az-product-gallery-wrapper {
  flex-direction: column-reverse;
  gap: 15px;
}
.az-layout-horizontal-top .az-product-gallery-main {
  width: 100%;
  order: 2;
}
.az-layout-horizontal-top .az-product-gallery-thumbs {
  width: 100%;
  order: 1;
}

/* 3. Vertical Left (Thumbs left of Main) */
.az-layout-vertical-left .az-product-gallery-wrapper {
  flex-direction: row-reverse;
  gap: 15px;
}
.az-layout-vertical-left .az-product-gallery-main {
  width: calc(100% - 100px);
}
.az-layout-vertical-left .az-product-gallery-thumbs {
  width: 85px;
  flex-shrink: 0;
}

/* 4. Vertical Right (Thumbs right of Main) */
.az-layout-vertical-right .az-product-gallery-wrapper {
  flex-direction: row;
  gap: 15px;
}
.az-layout-vertical-right .az-product-gallery-main {
  width: calc(100% - 100px);
}
.az-layout-vertical-right .az-product-gallery-thumbs {
  width: 85px;
  flex-shrink: 0;
}

/* Responsive adjustments for vertical layout on mobile */
@media (max-width: 767px) {
  .az-layout-vertical-left .az-product-gallery-wrapper,
  .az-layout-vertical-right .az-product-gallery-wrapper {
    flex-direction: column;
    gap: 10px;
  }
  .az-layout-vertical-left .az-product-gallery-main,
  .az-layout-vertical-right .az-product-gallery-main {
    width: 100%;
  }
  .az-layout-vertical-left .az-product-gallery-thumbs,
  .az-layout-vertical-right .az-product-gallery-thumbs {
    width: 100% !important;
    height: auto !important;
  }
}

/* ==========================================
   MAIN SLIDER STYLE
   ========================================== */
.az-product-gallery-main {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background-color: #ffffff;
}

.az-main-swiper {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Fallback before Swiper initializes to prevent height collapse and layout shifting */
.az-main-swiper:not(.swiper-initialized),
.az-thumbs-swiper:not(.swiper-initialized) {
  height: auto !important;
  display: block;
}

.az-main-swiper:not(.swiper-initialized) .swiper-wrapper,
.az-thumbs-swiper:not(.swiper-initialized) .swiper-wrapper {
  display: block !important;
  height: auto !important;
}

.az-main-swiper:not(.swiper-initialized) .swiper-slide:first-child,
.az-thumbs-swiper:not(.swiper-initialized) .swiper-slide {
  display: block !important;
  width: 100% !important;
  height: auto !important;
}

.az-main-swiper:not(.swiper-initialized) .swiper-slide:not(:first-child) {
  display: none !important;
}

.az-product-gallery-image {
  position: relative;
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
}

/* Aspect Ratios on Main Container */
.az-product-gallery-main.ratio-1-1 {
  aspect-ratio: 1 / 1;
}
.az-product-gallery-main.ratio-4-3 {
  aspect-ratio: 4 / 3;
}
.az-product-gallery-main.ratio-16-9 {
  aspect-ratio: 16 / 9;
}
.az-product-gallery-main.ratio-auto {
  height: auto;
}

/* Ensure Swiper elements stretch properly inside the main fixed aspect-ratio container */
.az-product-gallery-main:not(.ratio-auto) .az-main-swiper,
.az-product-gallery-main:not(.ratio-auto) .swiper-wrapper,
.az-product-gallery-main:not(.ratio-auto) .swiper-slide,
.az-product-gallery-main:not(.ratio-auto) .az-product-gallery-image {
  height: 100% !important;
}

/* Ensure auto aspect ratio works correctly without collapsing height */
.az-product-gallery-main.ratio-auto .az-main-swiper,
.az-product-gallery-main.ratio-auto .swiper-wrapper,
.az-product-gallery-main.ratio-auto .swiper-slide,
.az-product-gallery-main.ratio-auto .az-product-gallery-image {
  height: auto !important;
}

/* Image styling */
.az-product-gallery-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.az-product-gallery-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Zoom Hover Effect */
.az-zoomable {
  cursor: zoom-in;
}
.az-zoomable img {
  transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: center center;
}

/* ==========================================
   THUMBNAILS SLIDER STYLE
   ========================================== */
.az-product-gallery-thumbs {
  position: relative;
  overflow: hidden;
}

.az-thumbs-swiper {
  width: 100%;
  height: 100%;
}

.az-thumbs-swiper .swiper-slide {
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
  border-radius: 4px;
  box-sizing: border-box;
}

.az-thumbs-swiper .swiper-slide:hover {
  opacity: 1 !important;
}

.az-product-gallery-thumb-item {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
}

.az-product-gallery-thumb-item.ratio-1-1 {
  aspect-ratio: 1 / 1;
}
.az-product-gallery-thumb-item.ratio-4-3 {
  aspect-ratio: 4 / 3;
}
.az-product-gallery-thumb-item.ratio-16-9 {
  aspect-ratio: 16 / 9;
}
.az-product-gallery-thumb-item.ratio-auto {
  height: auto;
}

.az-product-gallery-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================
   NAVIGATION ARROWS
   ========================================== */
.az-product-gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--az-transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.az-arrow-prev {
  left: 15px;
}
.az-arrow-next {
  right: 15px;
}

/* Vertical Thumbnails Arrows (Image 1 style: Up/Down arrows) */
.az-thumb-arrow {
  position: absolute;
  z-index: 10;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: #ffffff;
  color: #1f2937;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: var(--az-transition);
  left: 50%;
  transform: translateX(-50%);
}

.az-thumb-arrow:hover {
  background-color: var(--az-active-border);
  color: #ffffff;
}

.az-layout-vertical-left .az-thumb-arrow-prev {
  top: -40px;
}
.az-layout-vertical-left .az-thumb-arrow-next {
  bottom: -40px;
}

.az-layout-vertical-right .az-thumb-arrow-prev {
  top: -40px;
}
.az-layout-vertical-right .az-thumb-arrow-next {
  bottom: -40px;
}

/* Keep spacing for arrows in vertical layout */
.az-layout-vertical-left .az-product-gallery-wrapper,
.az-layout-vertical-right .az-product-gallery-wrapper {
  margin-top: 40px;
  margin-bottom: 40px;
}

/* Horizontal Thumbnails Arrows (Image 2 style: Left/Right arrows) */
.az-thumb-arrow-horizontal {
  top: auto;
  bottom: 25px; /* Centered with thumbs roughly */
  transform: translateY(50%);
}

.az-layout-horizontal-bottom .az-thumb-arrow-prev {
  left: -20px;
  bottom: 35px;
  transform: none;
}
.az-layout-horizontal-bottom .az-thumb-arrow-next {
  right: -20px;
  bottom: 35px;
  transform: none;
}

.az-layout-horizontal-top .az-thumb-arrow-prev {
  left: -20px;
  top: 35px;
  transform: none;
}
.az-layout-horizontal-top .az-thumb-arrow-next {
  right: -20px;
  top: 35px;
  transform: none;
}

/* Responsive adjustment for mobile: Hide vertical arrows when they stack horizontally */
@media (max-width: 767px) {
  .az-layout-vertical-left .az-product-gallery-wrapper,
  .az-layout-vertical-right .az-product-gallery-wrapper {
    margin-top: 0;
    margin-bottom: 0;
  }
  .az-thumb-arrow {
    display: none !important;
  }
}

/* ==========================================
   VIDEO DISPLAY STYLING
   ========================================== */
.az-video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s ease, background-color 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.az-video-play-overlay:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.az-video-thumb-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.az-video-iframe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  background-color: #000000;
}

.az-video-iframe-container iframe,
.az-video-iframe-container video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.az-product-gallery-empty {
  padding: 30px;
  text-align: center;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  color: #6b7280;
  border-radius: 6px;
}
