/**
 * MN WooCommerce Product Gallery Widget Styles
 */

/* Editor Notice */
.mn-woo-gallery-editor-notice {
    padding: 20px;
    background: #f0f0f0;
    border: 1px dashed #ccc;
    text-align: center;
    color: #666;
    border-radius: 4px;
}

/* Gallery Wrapper */
.mn-woo-gallery-wrapper {
    position: relative;
    width: 100%;
}

/* Fix Elementor Sticky Duplication - hide the spacer/placeholder */
.elementor-sticky--effects ~ .elementor-sticky__spacer .mn-woo-gallery-wrapper,
.elementor-sticky__spacer .mn-woo-gallery-wrapper {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Alternative: if sticky is on column level */
.elementor-sticky__spacer .mn-woo-gallery-container {
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Sale Badge */
.mn-woo-gallery-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Gallery Container */
.mn-woo-gallery-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

/* Thumbnails Wrapper */
.mn-woo-gallery-thumbnails-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

/* Thumbnails Container */
.mn-woo-gallery-thumbnails {
    overflow: hidden;
    position: relative;
}

.mn-woo-gallery-thumbnails-inner {
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Thumbnail Item */
.mn-woo-gallery-thumb {
    cursor: pointer;
    overflow: hidden;
    border: 2px solid transparent;
    box-sizing: border-box;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.mn-woo-gallery-thumb:last-child {
    margin-bottom: 0 !important;
}

.mn-woo-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mn-woo-gallery-thumb.active {
    opacity: 1 !important;
    border-style: solid;
}

.mn-woo-gallery-thumb:hover {
    opacity: 1 !important;
}

/* Navigation Arrows (thumbnail strip) */
.mn-woo-gallery-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
    margin: 5px 0;
    /* Fix gepeng: force equal width & height */
    aspect-ratio: 1 / 1;
    min-width: 0;
    box-sizing: content-box;
}

.mn-woo-gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mn-woo-gallery-nav svg {
    width: 50%;
    height: 50%;
    flex-shrink: 0;
}

/* Main Image Container */
.mn-woo-gallery-main {
    position: relative;
    overflow: hidden;
    flex-grow: 1;
    cursor: pointer;
}

/* Main Image — Prev / Next Arrows */
.mn-woo-gallery-main-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    min-width: 40px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    pointer-events: auto;
}

.mn-woo-gallery-main:hover .mn-woo-gallery-main-nav {
    opacity: 1;
}

.mn-woo-gallery-main-nav:hover {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
}

.mn-woo-gallery-main-nav:disabled,
.mn-woo-gallery-main-nav.hidden {
    opacity: 0 !important;
    pointer-events: none;
}

.mn-woo-gallery-main-nav svg {
    flex-shrink: 0;
}

.mn-woo-gallery-main-prev {
    left: 12px;
}

.mn-woo-gallery-main-next {
    right: 12px;
}

.mn-woo-gallery-main-image {
    display: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
    backface-visibility: hidden;
}

.mn-woo-gallery-main-image.active {
    display: block;
}

.mn-woo-gallery-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Video items — let video wrapper determine its own height */
.mn-gallery-main-video {
    position: relative;
    height: auto !important;
    inset: unset;
    width: 100%;
}

/* Lightbox Styles */
.mn-woo-gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
}

.mn-woo-gallery-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.mn-woo-gallery-lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mn-woo-gallery-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.mn-woo-gallery-lightbox-close:hover {
    opacity: 0.7;
}

.mn-woo-gallery-lightbox-prev,
.mn-woo-gallery-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    z-index: 10;
}

.mn-woo-gallery-lightbox-prev:hover,
.mn-woo-gallery-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mn-woo-gallery-lightbox-prev {
    left: 20px;
}

.mn-woo-gallery-lightbox-next {
    right: 20px;
}

.mn-woo-gallery-lightbox-image {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mn-woo-gallery-lightbox-image img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

/* =============================================
   Video Gallery Items
   ============================================= */

/* Video wrapper — responsive 16:9 container */
.mn-gallery-video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    background: #000;
    overflow: hidden;
}

/* Poster / thumbnail with play button (embed videos) */
.mn-gallery-video-poster {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.mn-gallery-video-poster.hidden {
    opacity: 0;
    pointer-events: none;
}

.mn-gallery-video-play-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #222;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
}

.mn-gallery-video-play-btn:hover {
    transform: scale(1.1);
    background: #fff;
}

.mn-gallery-video-play-btn svg {
    margin-left: 4px; /* optical center for play triangle */
}

/* iframe container (hidden until play is clicked) */
.mn-gallery-video-iframe-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.mn-gallery-video-iframe-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* HTML5 video file */
.mn-gallery-video-file video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

/* Thumbnail — play icon overlay */
.mn-woo-gallery-thumb.mn-gallery-thumb-video {
    position: relative;
}

.mn-gallery-thumb-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    pointer-events: none;
    border-radius: inherit;
}

/* Placeholder when no thumbnail available */
.mn-gallery-thumb-video-placeholder {
    width: 100%;
    height: 100%;
    background: #1a1a1a;
}

/* Zoom icon — hide on video slides */
.mn-gallery-main-video .mn-woo-gallery-zoom-icon {
    display: none !important;
}

/* Zoom Icon Overlay */
.mn-woo-gallery-zoom-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.mn-woo-gallery-zoom-icon svg {
    width: 24px;
    height: 24px;
}

.mn-woo-gallery-main:hover .mn-woo-gallery-zoom-icon {
    opacity: 1;
}

/* =============================================
   Thumbnail Position Variants
   ============================================= */

/* Position: Right */
.mn-gallery-pos-right .mn-woo-gallery-container {
    flex-direction: row-reverse;
}

/* Position: Top */
.mn-gallery-pos-top .mn-woo-gallery-container {
    flex-direction: column;
}

.mn-gallery-pos-top .mn-woo-gallery-thumbnails-wrapper {
    flex-direction: row;
    width: 100%;
    margin-bottom: 10px;
}

.mn-gallery-pos-top .mn-woo-gallery-thumbnails {
    width: 100% !important;
    height: auto !important;
}

.mn-gallery-pos-top .mn-woo-gallery-thumbnails-inner {
    flex-direction: row;
    gap: 10px;
}

.mn-gallery-pos-top .mn-woo-gallery-thumb {
    margin-bottom: 0 !important;
}

.mn-gallery-pos-top .mn-woo-gallery-nav {
    transform: rotate(-90deg);
}

/* Position: Bottom */
.mn-gallery-pos-bottom .mn-woo-gallery-container {
    flex-direction: column-reverse;
}

.mn-gallery-pos-bottom .mn-woo-gallery-thumbnails-wrapper {
    flex-direction: row;
    width: 100%;
    margin-top: 10px;
}

.mn-gallery-pos-bottom .mn-woo-gallery-thumbnails {
    width: 100% !important;
    height: auto !important;
}

.mn-gallery-pos-bottom .mn-woo-gallery-thumbnails-inner {
    flex-direction: row;
    gap: 10px;
}

.mn-gallery-pos-bottom .mn-woo-gallery-thumb {
    margin-bottom: 0 !important;
}

.mn-gallery-pos-bottom .mn-woo-gallery-nav {
    transform: rotate(-90deg);
}

/* =============================================
   Responsive
   ============================================= */

/* Tablet */
@media (max-width: 1024px) and (min-width: 768px) {
    .mn-woo-gallery-main {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 4 / 3;
    }
    
    .mn-woo-gallery-main-image img {
        object-fit: contain;
    }
}

/* Mobile — hide main arrows, enable touch swipe cursor */
@media (max-width: 767px) {
    .mn-woo-gallery-main-nav {
        display: none !important;
    }
    .mn-woo-gallery-main {
        touch-action: pan-y;
        cursor: grab;
    }
    .mn-woo-gallery-main.mn-swiping {
        cursor: grabbing;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mn-woo-gallery-container {
        flex-direction: column-reverse !important;
    }
    
    .mn-woo-gallery-thumbnails-wrapper {
        flex-direction: row;
        width: 100%;
        margin-top: 10px;
        flex:none;
    }
    
    .mn-woo-gallery-thumbnails {
        width: 100% !important;
        height: auto !important;
    }
    
    .mn-woo-gallery-thumbnails-inner {
        flex-direction: row;
        gap: 10px;
    }
    
    .mn-woo-gallery-thumb {
        margin-bottom: 0 !important;
        width: 60px !important;
        height: 60px !important;
    }
    
    .mn-woo-gallery-nav {
        transform: rotate(-90deg);
    }
    
    .mn-woo-gallery-main {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
        flex:none;
    }
    
    .mn-woo-gallery-main-image img {
        object-fit: contain;
    }
    
    .mn-woo-gallery-lightbox-prev,
    .mn-woo-gallery-lightbox-next {
        width: 40px;
        height: 40px;
    }
    
    .mn-woo-gallery-lightbox-prev {
        left: 10px;
    }
    
    .mn-woo-gallery-lightbox-next {
        right: 10px;
    }
}
