/* Mouheb Woo Image General Styles */
.mouheb-woo-image-wrapper {
    display: flex;
    position: relative;
}

/* Main Image Styles */
.mwi-main-image-container {
    position: relative;
    overflow: hidden;
    cursor: crosshair; /* For zoom hint */
    height: 500px; /* Default height, controlled by widget settings */
    flex-grow: 1;
    min-width: 0; /* Fix for flexbox overflow issues */
}

.mwi-main-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Default, controlled by widget settings */
    transition: transform 0.3s ease-out, opacity 0.2s linear;
}

/* Thumbnails Wrapper */
.mwi-thumbnails-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.mwi-thumbnails-inner {
    display: flex;
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
    scroll-behavior: smooth;
    flex-grow: 1;
    padding: 5px; /* Padding to prevent border clipping on active */
}

.mwi-thumbnails-inner::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Thumbnail Item */
.mwi-thumbnail-item {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
    flex-shrink: 0; /* Prevent thumbnails from shrinking */
}

.mwi-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mwi-thumbnail-item:hover {
    opacity: 1;
}

.mwi-thumbnail-item.mwi-active {
    opacity: 1;
    border-color: #007cba; /* Example active color */
    box-shadow: 0 0 10px rgba(0, 124, 186, 0.5);
}

/* Navigation Arrows */
.mwi-arrow {
    cursor: pointer;
    z-index: 10;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
    user-select: none;
}

.mwi-arrow:hover {
    background: #fff;
    color: #000;
}

.mwi-arrow.mwi-disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* --- DESKTOP LAYOUTS --- */

/* Position: Bottom (Default) */
.mwi-gallery-position-bottom .mouheb-woo-image-wrapper {
    flex-direction: column;
}
.mwi-gallery-position-bottom .mwi-thumbnails-inner {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
}
.mwi-gallery-position-bottom .mwi-arrow-prev { order: -1; }
.mwi-gallery-position-bottom .mwi-arrow-next { order: 1; }

/* Position: Left */
.mwi-gallery-position-left .mouheb-woo-image-wrapper {
    flex-direction: row-reverse;
}

/* Position: Right */
.mwi-gallery-position-right .mouheb-woo-image-wrapper {
    flex-direction: row;
}

/* Common for Desktop Left/Right */
.mwi-gallery-position-left .mwi-thumbnails-wrapper,
.mwi-gallery-position-right .mwi-thumbnails-wrapper {
    flex-direction: column;
    height: 100%;
}
.mwi-gallery-position-left .mwi-thumbnails-inner,
.mwi-gallery-position-right .mwi-thumbnails-inner {
    flex-direction: column;
    height: 100%; /* JS will override if visible count is set */
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 40px;
    padding-bottom: 40px;
}
.mwi-gallery-position-left .mwi-arrow,
.mwi-gallery-position-right .mwi-arrow {
    position: absolute;
    left: 0;
    right: 0;
}
.mwi-gallery-position-left .mwi-arrow-prev,
.mwi-gallery-position-right .mwi-arrow-prev { top: 0; }
.mwi-gallery-position-left .mwi-arrow-next,
.mwi-gallery-position-right .mwi-arrow-next { bottom: 0; }


/* --- VERTICAL FADE EFFECT (Desktop Only) --- */
.mwi-thumbnails-wrapper.mwi-is-vertical::before,
.mwi-thumbnails-wrapper.mwi-is-vertical::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 45px;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 0;
}
.mwi-thumbnails-wrapper.mwi-is-vertical::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 0));
}
.mwi-thumbnails-wrapper.mwi-is-vertical::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 0));
}
.mwi-thumbnails-wrapper.mwi-scrolled-top::before,
.mwi-thumbnails-wrapper.mwi-scrolled-bottom::after {
    opacity: 1;
}


/* --- MOBILE RESPONSIVE STYLES (max-width: 767px) --- */
@media (max-width: 767px) {
    /* Force all layouts to stack vertically */
    .mouheb-woo-image-wrapper {
        flex-direction: column !important;
    }

    /* Reset thumbnail wrapper for horizontal layout */
    .mwi-thumbnails-wrapper {
        flex-direction: row !important;
        width: 100% !important;
        height: auto !important;
        margin-top: 15px;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Ensure inner container scrolls horizontally */
    .mwi-thumbnails-inner {
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        height: auto !important;
        padding: 5px !important; /* Reset vertical padding */
    }

    /* Reset arrow positions for horizontal layout */
    .mwi-arrow {
        position: static !important;
        transform: none !important;
    }
    .mwi-arrow-prev { order: -1; }
    .mwi-arrow-next { order: 1; }
}


/* Lightbox Styles */
.mwi-lightbox {
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
}
.mwi-lightbox-content {
    max-width: 90%;
    max-height: 90%;
    animation: mwi-lightbox-zoom 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
@keyframes mwi-lightbox-zoom {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.mwi-lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}
.mwi-lightbox-close:hover,
.mwi-lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
}
