/* Base Wrapper */
.wc-adv-gallery-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

/* Base Main Slider */
.wc-adv-main-slider {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
    border: 1px solid #eaeaea;
    position: relative;
}

.main-slide img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* Zoom Icon Overlay */
.wc-adv-zoom-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: transform 0.2s, background 0.2s;
}

.wc-adv-zoom-icon:hover {
    background: #ffffff;
    transform: scale(1.05);
}

.wc-adv-zoom-icon svg {
    color: #333;
}

/* Base Thumb Slider */
.wc-adv-thumb-slider {
    width: 100%;
    padding: 2px 0;
    box-sizing: border-box;
    overflow: hidden;
}

.thumb-slide {
    width: 25%; /* Roughly for 4-5 thumbnails config */
    height: 100px; /* Base height, adjusted by swiper ratio */
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    box-sizing: border-box;
    padding: 2px;
}

.thumb-slide:hover {
    opacity: 1;
}

.thumb-slide.swiper-slide-thumb-active {
    opacity: 1;
    border-color: #007185; /* Blue border matching screenshot */
    box-shadow: 0 0 5px rgba(0, 113, 133, 0.3);
}

.thumb-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

/* Dots vs Thumbnails Visibility Classes */
.wc-adv-gallery-wrapper.use-dots .wc-adv-thumb-slider {
    display: none !important;
}

.wc-adv-gallery-wrapper.use-dots .wc-adv-pagination {
    display: block !important;
    position: relative; /* Bring dots below the image instead of over it */
    margin-top: 15px;
}

.wc-adv-gallery-wrapper.use-thumbs .wc-adv-thumb-slider {
    display: block !important;
}

.wc-adv-gallery-wrapper.use-thumbs .wc-adv-pagination {
    display: none !important;
}

/* Swiper Arrows Overrides */
.wc-adv-gallery-wrapper .swiper-button-next,
.wc-adv-gallery-wrapper .swiper-button-prev {
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
}

.wc-adv-gallery-wrapper .swiper-button-next::after,
.wc-adv-gallery-wrapper .swiper-button-prev::after {
    font-size: 16px;
    font-weight: bold;
}

/* Hide Main Arrows when configured */
.wc-adv-gallery-wrapper.hide-main-arrows .wc-adv-next,
.wc-adv-gallery-wrapper.hide-main-arrows .wc-adv-prev {
    display: none !important;
}

/* Thumbnail Arrows */
.wc-adv-thumb-next,
.wc-adv-thumb-prev {
    width: 24px;
    height: 24px;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    margin-top: -12px;
}
.wc-adv-thumb-next::after,
.wc-adv-thumb-prev::after {
    font-size: 10px;
    font-weight: bold;
}
.wc-adv-thumb-slider {
    position: relative;
    padding: 0 24px; /* Space for horizontal arrows */
    margin: 0 -24px; /* Compensate for padding to stay aligned with main image */
}

/* Admin Configurations for Layout (Desktop mostly) */
@media screen and (min-width: 768px) {
    /* Left */
    .wc-adv-gallery-wrapper.pos-left {
        flex-direction: row-reverse;
    }
    /* Right */
    .wc-adv-gallery-wrapper.pos-right {
        flex-direction: row;
    }
    /* Top */
    .wc-adv-gallery-wrapper.pos-top {
        flex-direction: column-reverse;
    }
    
    /* Flex widths when Side-by-side */
    .wc-adv-gallery-wrapper.pos-left .wc-adv-main-slider,
    .wc-adv-gallery-wrapper.pos-right .wc-adv-main-slider {
        width: calc(85% - 15px);
    }
    
    .wc-adv-gallery-wrapper.pos-left .wc-adv-thumb-slider,
    .wc-adv-gallery-wrapper.pos-right .wc-adv-thumb-slider {
        width: 15%;
        padding: 24px 0; /* Space for vertical arrows */
        margin: -24px 0;
    }

    /* Vertical Orientation Arrows positioning */
    .wc-adv-gallery-wrapper.pos-left .wc-adv-thumb-prev,
    .wc-adv-gallery-wrapper.pos-right .wc-adv-thumb-prev {
        top: 12px;
        left: 50%;
        transform: translateX(-50%) rotate(90deg);
        margin-top: 0;
    }
    
    .wc-adv-gallery-wrapper.pos-left .wc-adv-thumb-next,
    .wc-adv-gallery-wrapper.pos-right .wc-adv-thumb-next {
        top: auto;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%) rotate(90deg);
        margin-top: 0;
    }
    
    .wc-adv-gallery-wrapper.pos-left .thumb-slide,
    .wc-adv-gallery-wrapper.pos-right .thumb-slide {
        height: auto;
        aspect-ratio: 1/1; /* Keep square thumbnails on vertical layout */
    }
}

/* Order PhotoSwipe Buttons */
.pswp__top-bar {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
}
.pswp__counter {
    margin-right: auto !important;
    position: relative !important;
    float: none !important;
}
.pswp__top-bar .pswp__button {
    float: none !important;
    position: relative !important;
    display: block;
}
.pswp__top-bar .pswp__button--zoom {
    order: 1 !important;
}
.pswp__top-bar .pswp__button--fs {
    order: 2 !important;
}
.pswp__top-bar .pswp__button--close {
    order: 3 !important;
}

/* Ensure main arrows are always visible when not specifically hidden */
.wc-adv-gallery-wrapper:not(.hide-main-arrows) .wc-adv-next,
.wc-adv-gallery-wrapper:not(.hide-main-arrows) .wc-adv-prev {
    display: flex !important;
}

/* Image Fit Modes */
.wc-adv-main-slider:not(.auto-height) {
    aspect-ratio: var(--gallery-aspect-ratio, 1 / 1);
}
.wc-adv-gallery-wrapper.fit-cover .main-slide img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}
.wc-adv-gallery-wrapper.fit-contain .main-slide img {
    object-fit: contain;
    width: 100%;
    height: 100%;
    background-color: transparent;
}
.wc-adv-gallery-wrapper.fit-auto .main-slide img {
    object-fit: contain;
    width: 100%;
    height: auto;
}
