/**
 * WooCommerce Product Gallery - Frontend Styles
 *
 * Supports three thumbnail positions: bottom, left, right.
 * Built with Flexbox for clean, responsive layouts.
 */

/* ==========================================================================
   CSS Variables (Easy theming)
   ========================================================================== */

:root {
    --wcg-gap: 12px;
    --wcg-thumb-size-horizontal: 72px;
    --wcg-thumb-size-vertical: 72px;
    --wcg-thumb-strip-width: 90px;
    --wcg-thumb-border-radius: 6px;
    --wcg-main-border-radius: 8px;
    --wcg-nav-size: 40px;
    --wcg-nav-bg: rgba(255, 255, 255, 0.92);
    --wcg-nav-color: #333;
    --wcg-nav-hover-bg: #fff;
    --wcg-nav-hover-color: #333;
    --wcg-nav-radius: 50%;
    --wcg-nav-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    --wcg-active-border: #000;
    --wcg-active-border-width: 2px;
    --wcg-inactive-opacity: 0.5;
    --wcg-dot-color: #ccc;
    --wcg-dot-active: #333;
    --wcg-transition: 0.3s ease;
}

/* ==========================================================================
   Gallery Container (common for all positions)
   ========================================================================== */

.wcg-gallery {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.wcg-gallery *,
.wcg-gallery *::before,
.wcg-gallery *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   POSITION: BOTTOM (default - like screenshot)
   ========================================================================== */

.wcg-gallery.wcg-position-bottom {
    flex-direction: column;
    gap: var(--wcg-gap);
}

.wcg-position-bottom .wcg-main-wrapper {
    width: 100%;
    position: relative;
}

.wcg-position-bottom .wcg-thumbnails-wrapper {
    width: 100%;
    position: relative;
    padding: 0 30px; /* space for nav arrows */
    min-height: var(--wcg-thumb-size-horizontal);
    margin-bottom: 0;
}

.wcg-position-bottom .wcg-thumb-slider {
    overflow: hidden;
    height: var(--wcg-thumb-size-horizontal);
}

.wcg-position-bottom .wcg-thumb-slider .swiper-wrapper {
    align-items: center;
}

.wcg-position-bottom .wcg-thumb-slider .swiper-slide {
    width: var(--wcg-thumb-size-horizontal);
    height: var(--wcg-thumb-size-horizontal);
    flex-shrink: 0;
    box-sizing: border-box;
    margin-bottom: 0;
}

/* ==========================================================================
   POSITION: LEFT
   ========================================================================== */

.wcg-gallery.wcg-position-left {
    flex-direction: row;
    gap: var(--wcg-gap);
}

.wcg-position-left .wcg-thumbnails-wrapper {
    width: var(--wcg-thumb-strip-width);
    min-width: var(--wcg-thumb-strip-width);
    position: relative;
    order: -1;
    padding: 28px 0; /* space for nav arrows top/bottom */
}

.wcg-position-left .wcg-main-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

.wcg-position-left .wcg-thumb-slider {
    height: 100%;
    overflow: hidden;
}

.wcg-position-left .wcg-thumb-slider .swiper-wrapper {
    flex-direction: column;
    align-items: center;
}

.wcg-position-left .wcg-thumb-slider .swiper-slide {
    width: 100%;
    height: var(--wcg-thumb-size-vertical);
    flex-shrink: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   POSITION: RIGHT
   ========================================================================== */

.wcg-gallery.wcg-position-right {
    flex-direction: row;
    gap: var(--wcg-gap);
}

.wcg-position-right .wcg-main-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

.wcg-position-right .wcg-thumbnails-wrapper {
    width: var(--wcg-thumb-strip-width);
    min-width: var(--wcg-thumb-strip-width);
    position: relative;
    padding: 28px 0; /* space for nav arrows top/bottom */
}

.wcg-position-right .wcg-thumb-slider {
    height: 100%;
    overflow: hidden;
}

.wcg-position-right .wcg-thumb-slider .swiper-wrapper {
    flex-direction: column;
    align-items: center;
}

.wcg-position-right .wcg-thumb-slider .swiper-slide {
    width: 100%;
    height: var(--wcg-thumb-size-vertical);
    flex-shrink: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   Main Image Slider
   ========================================================================== */

.wcg-main-slider {
    width: 100%;
    overflow: hidden;
    border-radius: var(--wcg-main-border-radius);
    background-color: #f8f8f8;
    position: relative;
}

.wcg-main-slider .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8f8f8;
}

.wcg-main-slider .swiper-slide img.wcg-main-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    max-height: 600px;
    cursor: pointer;
    transition: transform var(--wcg-transition);
}

.wcg-main-slider .swiper-slide a {
    display: block;
    width: 100%;
    line-height: 0;
}

/* ==========================================================================
   Navigation Arrows (Main Slider)
   ========================================================================== */

.wcg-gallery .wcg-nav-prev,
.wcg-gallery .wcg-nav-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: var(--wcg-nav-size);
    height: var(--wcg-nav-size);
    border-radius: var(--wcg-nav-radius);
    background: var(--wcg-nav-bg);
    color: var(--wcg-nav-color);
    border: none;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wcg-nav-shadow);
    transition: all var(--wcg-transition);
    opacity: 1 !important;
    visibility: visible !important;
    padding: 0;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.wcg-nav-prev:hover,
.wcg-nav-next:hover {
    background: var(--wcg-nav-hover-bg);
    color: var(--wcg-nav-hover-color);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    transform: translateY(-50%) scale(1.05);
}

.wcg-nav-prev:active,
.wcg-nav-next:active {
    transform: translateY(-50%) scale(0.95);
}

.wcg-nav-prev {
    left: 12px;
}

.wcg-nav-next {
    right: 12px;
}

.wcg-nav-prev svg,
.wcg-nav-next svg {
    flex-shrink: 0;
    pointer-events: none;
}

/* Dim when Swiper adds disabled class (at start/end if not loop) - keep visible */
.wcg-gallery .wcg-nav-prev.swiper-button-disabled,
.wcg-gallery .wcg-nav-next.swiper-button-disabled {
    opacity: 0.3 !important;
    visibility: visible !important;
    cursor: default;
    pointer-events: none;
}

/* ==========================================================================
   Pagination Dots
   ========================================================================== */

.wcg-pagination {
    position: absolute;
    bottom: 14px;
    left: 0;
    right: 0;
    z-index: 10;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px 0;
}

.wcg-pagination .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wcg-dot-color);
    opacity: 1;
    cursor: pointer;
    transition: all var(--wcg-transition);
    border: none;
    display: inline-block;
}

.wcg-pagination .swiper-pagination-bullet-active {
    background: var(--wcg-dot-active);
    width: 24px;
    border-radius: 4px;
}

/* Hide dots when only one image */
.wcg-gallery[data-single-image="true"] .wcg-pagination {
    display: none;
}

/* ==========================================================================
   Thumbnails (Shared styles)
   IMPORTANT: Border is on the SLIDE container (not img) to avoid overflow clip
   Active class from Swiper thumbs module: swiper-slide-thumb-active
   ========================================================================== */

.wcg-thumbnails-wrapper {
    margin-bottom: 0;
}

.wcg-thumb-slider .swiper-slide {
    margin-bottom: 0;
}

.wcg-thumb-slide {
    cursor: pointer;
    border-radius: var(--wcg-thumb-border-radius);
    overflow: hidden;
    transition: all var(--wcg-transition);
    border: var(--wcg-active-border-width) solid transparent;
    padding: 0;
    margin-bottom: 0;
}

.wcg-thumb-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--wcg-thumb-border-radius) - var(--wcg-active-border-width));
    opacity: var(--wcg-inactive-opacity);
    transition: opacity var(--wcg-transition);
}

.wcg-thumb-slide:hover img {
    opacity: 0.85;
}

/* Swiper's built-in thumb active class */
.wcg-thumb-slide.swiper-slide-thumb-active {
    border-color: var(--wcg-active-border);
}

.wcg-thumb-slide.swiper-slide-thumb-active img {
    opacity: 1;
}

/* Also support our manual class as fallback */
.wcg-thumb-slide.wcg-thumb-active {
    border-color: var(--wcg-active-border);
}

.wcg-thumb-slide.wcg-thumb-active img {
    opacity: 1;
}

/* ==========================================================================
   Thumbnail Navigation Arrows
   ========================================================================== */

/* Horizontal (bottom position) */
.wcg-position-bottom .wcg-thumb-prev,
.wcg-position-bottom .wcg-thumb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #555;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--wcg-transition);
    padding: 0;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.wcg-position-bottom .wcg-thumb-prev {
    left: 0;
}

.wcg-position-bottom .wcg-thumb-next {
    right: 0;
}

.wcg-position-bottom .wcg-thumb-prev:hover,
.wcg-position-bottom .wcg-thumb-next:hover {
    background: #fff;
    border-color: #999;
}

/* Vertical (left/right position) */
.wcg-position-left .wcg-thumb-prev,
.wcg-position-left .wcg-thumb-next,
.wcg-position-right .wcg-thumb-prev,
.wcg-position-right .wcg-thumb-next {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #555;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--wcg-transition);
    padding: 0;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.wcg-position-left .wcg-thumb-prev,
.wcg-position-right .wcg-thumb-prev {
    top: 0;
}

.wcg-position-left .wcg-thumb-next,
.wcg-position-right .wcg-thumb-next {
    bottom: 0;
}

.wcg-position-left .wcg-thumb-prev:hover,
.wcg-position-left .wcg-thumb-next:hover,
.wcg-position-right .wcg-thumb-prev:hover,
.wcg-position-right .wcg-thumb-next:hover {
    background: #fff;
    border-color: #999;
}

/* Hide thumb nav when not needed */
.wcg-thumb-prev.wcg-hidden,
.wcg-thumb-next.wcg-hidden {
    display: none;
}

/* ==========================================================================
   Zoom Styles
   ========================================================================== */

.wcg-main-image.wcg-zoom-target {
    cursor: crosshair;
}

.drift-zoom-pane {
    z-index: 100;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.drift-zoom-pane img {
    max-width: none !important;
}

.drift-bounding-box {
    border: 2px solid rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Lightbox Overrides
   ========================================================================== */

.glightbox-clean .gslide-title {
    font-size: 14px;
    font-weight: 500;
}

.glightbox-clean .gslide-description {
    background: transparent;
}

/* Make lightbox feel more premium */
.glightbox-clean .goverlay {
    background: rgba(15, 23, 42, 0.96);
}

.glightbox-clean .ginner-container {
    max-width: 1120px;
    padding: 32px 16px;
}

.glightbox-clean .gslide {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
}

.glightbox-clean .gslide-inner-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.glightbox-clean .gslide-media {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100vh - 180px); /* leave room for caption + controls */
}

.glightbox-clean .gslide-media img {
    max-width: min(80vw, 880px);
    max-height: calc(100vh - 220px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.6);
}

/* Caption area - small, subtle text below image */
.glightbox-clean .gslide-description {
    max-width: 880px;
    margin: 18px auto 0;
    padding: 0;
    color: #e5e7eb;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

.glightbox-clean .gslide-title {
    color: #f9fafb;
    text-align: center;
    margin-bottom: 4px;
}

/* Navigation + Close buttons - modern circular buttons */
.glightbox-clean .gprev,
.glightbox-clean .gnext,
.glightbox-clean .gclose {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.glightbox-clean .gprev:hover,
.glightbox-clean .gnext:hover,
.glightbox-clean .gclose:hover {
    background: rgba(30, 64, 175, 0.96);
    border-color: rgba(129, 140, 248, 0.9);
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 14px 40px rgba(30, 64, 175, 0.85);
}

.glightbox-clean .gprev svg,
.glightbox-clean .gnext svg,
.glightbox-clean .gclose svg {
    width: 18px;
    height: 18px;
}

/* Position tweaks */
.glightbox-clean .gprev {
    left: 32px;
}

.glightbox-clean .gnext {
    right: 32px;
}

.glightbox-clean .gclose {
    top: 26px;
    right: 32px;
}

/* Mobile: buttons a bit smaller / closer */
@media (max-width: 767px) {
    .glightbox-clean .ginner-container {
        padding: 16px 10px;
    }

    .glightbox-clean .gslide {
        min-height: calc(100vh - 40px);
    }

    .glightbox-clean .gslide-media {
        max-height: calc(100vh - 150px);
    }

    .glightbox-clean .gslide-media img {
        max-width: 92vw;
        max-height: calc(100vh - 170px);
        border-radius: 10px;
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.7);
    }

    .glightbox-clean .gprev,
    .glightbox-clean .gnext,
    .glightbox-clean .gclose {
        width: 34px;
        height: 34px;
    }

    .glightbox-clean .gprev {
        left: 14px;
    }

    .glightbox-clean .gnext {
        right: 14px;
    }

    .glightbox-clean .gclose {
        top: 16px;
        right: 14px;
    }

    .glightbox-clean .gslide-description {
        font-size: 12px;
        padding: 0 6px;
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --wcg-thumb-size-horizontal: 64px;
        --wcg-thumb-size-vertical: 64px;
        --wcg-thumb-strip-width: 80px;
    }

    .wcg-main-slider .swiper-slide img.wcg-main-image {
        max-height: 500px;
    }
}

/* Mobile - always switch to bottom layout */
@media (max-width: 767px) {
    :root {
        --wcg-thumb-size-horizontal: 56px;
        --wcg-thumb-size-vertical: 56px;
        --wcg-nav-size: 34px;
    }

    /* Force bottom layout on mobile for left/right */
    .wcg-gallery.wcg-position-left,
    .wcg-gallery.wcg-position-right {
        flex-direction: column;
        gap: var(--wcg-gap);
    }

    .wcg-position-left .wcg-thumbnails-wrapper,
    .wcg-position-right .wcg-thumbnails-wrapper {
        width: 100%;
        min-width: 100%;
        order: 0;
        padding: 0 30px;
    }

    .wcg-position-left .wcg-thumb-slider .swiper-wrapper,
    .wcg-position-right .wcg-thumb-slider .swiper-wrapper {
        flex-direction: row;
    }

    .wcg-position-left .wcg-thumb-slider .swiper-slide,
    .wcg-position-right .wcg-thumb-slider .swiper-slide {
        height: var(--wcg-thumb-size-horizontal);
    }

    /* Change vertical nav to horizontal on mobile */
    .wcg-position-left .wcg-thumb-prev,
    .wcg-position-left .wcg-thumb-next,
    .wcg-position-right .wcg-thumb-prev,
    .wcg-position-right .wcg-thumb-next {
        top: 50%;
        left: auto;
        transform: translateY(-50%);
    }

    .wcg-position-left .wcg-thumb-prev,
    .wcg-position-right .wcg-thumb-prev {
        left: 0;
        bottom: auto;
    }

    .wcg-position-left .wcg-thumb-next,
    .wcg-position-right .wcg-thumb-next {
        right: 0;
        left: auto;
        bottom: auto;
    }

    .wcg-main-slider .swiper-slide img.wcg-main-image {
        max-height: 400px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    :root {
        --wcg-thumb-size-horizontal: 48px;
        --wcg-thumb-size-vertical: 48px;
        --wcg-gap: 8px;
    }

    .wcg-main-slider .swiper-slide img.wcg-main-image {
        max-height: 320px;
    }
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.wcg-gallery.wcg-loading .wcg-main-slider {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcg-gallery.wcg-loading .wcg-main-slider::after {
    content: '';
    width: 36px;
    height: 36px;
    border: 3px solid #eee;
    border-top-color: #999;
    border-radius: 50%;
    animation: wcg-spin 0.8s linear infinite;
}

@keyframes wcg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .wcg-gallery.wcg-position-left {
    flex-direction: row-reverse;
}

[dir="rtl"] .wcg-gallery.wcg-position-right {
    flex-direction: row;
}

[dir="rtl"] .wcg-nav-prev {
    left: auto;
    right: 12px;
}

[dir="rtl"] .wcg-nav-next {
    right: auto;
    left: 12px;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wcg-nav-prev,
    .wcg-nav-next,
    .wcg-pagination,
    .wcg-thumb-prev,
    .wcg-thumb-next {
        display: none !important;
    }

    .wcg-gallery {
        flex-direction: column !important;
    }

    .wcg-main-slider .swiper-slide:not(:first-child) {
        display: none !important;
    }
}
