/**
 * Custom WooCommerce Vertical Product Gallery CSS (Updated with thumbnail limits)
 */

/* Gallery container */
.n-theme-product-gallery {
    display: flex;
    gap: 15px;
    width: 100%;
}

/* Thumbnails wrapper */
.n-theme-gallery-thumbnails-wrapper {
    display: flex;
    position: relative;
    width: auto;
}

/* Thumbnails container - Fixed height for limiting visible thumbnails */
.n-theme-gallery-thumbnails {
    width: 100px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc((80px + 10px) * 5); /* Height for 5 visible thumbnails */
    overflow: hidden!important; /* Hide overflow initially */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* When there are more than 5 thumbnails, enable scrolling */
.n-theme-gallery-thumbnails[data-visible] {
    overflow-y: auto;
}

/* Individual thumbnail */
.n-theme-gallery-thumbnail {
    width: 80px;
    height: 80px;
    min-width: 80px;
    flex-shrink: 0; /* Prevent thumbnails from shrinking */
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    overflow: hidden;
}

.n-theme-gallery-thumbnail:hover {
    opacity: 0.9;
    border-color: #aaa;
}

.n-theme-gallery-thumbnail.active {
    opacity: 1;
    border-color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.n-theme-gallery-thumbnail img {
    width: 100%;
    height: 100%!important;
    object-fit: cover;
    display: block;
}

/* Main image container - remaining CSS stays the same */
.n-theme-gallery-main {
    flex: 1;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

/* Individual main image */
.n-theme-gallery-main-image {
    display: none;
    width: 100%;
    height: 100%;
}

.n-theme-gallery-main-image.active {
    display: block;
}

.n-theme-gallery-main-image img {
    width: 100%;
    height: 100%!important;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

/* Thumbnail navigation arrows - improved visibility and positioning */
.n-theme-gallery-thumb-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgb(22 22 22);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: all 0.2s ease;
}
.n-theme-gallery-thumbnails-wrapper:hover .n-theme-gallery-thumb-nav{
    opacity: 1;
}

.n-theme-gallery-thumb-nav:hover {
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.n-theme-gallery-thumb-nav:before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-style: solid;
    border-width: 0 2px 2px 0;
    border-color: #fff;
}

.n-theme-gallery-thumb-nav:hover:before {
    border-color: #333;
}

/* Vertical layout thumbnail arrows */
.n-theme-gallery-layout-vertical .n-theme-gallery-thumb-nav.prev {
    top: -12px;
}

.n-theme-gallery-layout-vertical .n-theme-gallery-thumb-nav.prev:before {
    transform: rotate(-135deg);
}

.n-theme-gallery-layout-vertical .n-theme-gallery-thumb-nav.next {
    bottom: -12px;
}

.n-theme-gallery-layout-vertical .n-theme-gallery-thumb-nav.next:before {
    transform: rotate(45deg);
}

/* Horizontal layout thumbnail arrows (for mobile) */
.n-theme-gallery-layout-horizontal .n-theme-gallery-thumbnails {
    max-height: none;
    max-width: calc((60px + 8px) * 5); /* Width for 5 visible thumbnails on mobile */
    overflow-x: hidden;
}

.n-theme-gallery-layout-horizontal .n-theme-gallery-thumb-nav.prev {
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
}

.n-theme-gallery-layout-horizontal .n-theme-gallery-thumb-nav.prev:before {
    transform: rotate(135deg);
}

.n-theme-gallery-layout-horizontal .n-theme-gallery-thumb-nav.next {
    right: -12px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
}

.n-theme-gallery-layout-horizontal .n-theme-gallery-thumb-nav.next:before {
    transform: rotate(-45deg);
}


.n-theme-gallery-nav {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 40px !important;
    height: 40px !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-radius: 50% !important;
    z-index: 999 !important;
    cursor: pointer !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.n-theme-gallery-nav:before {
    content: '' !important;
    display: block !important;
    width: 10px !important;
    height: 10px !important;
    border-top: 2px solid white !important;
    border-right: 2px solid white !important;
}

.n-theme-gallery-nav.prev {
    left: 10px !important;
}

.n-theme-gallery-nav.prev:before {
    transform: rotate(-135deg) !important;
    margin-left: 4px !important;
}

.n-theme-gallery-nav.next {
    right: 10px !important;
}

.n-theme-gallery-nav.next:before {
    transform: rotate(45deg) !important;
    margin-right: 4px !important;
}

/* Responsive styles */
@media (max-width: 1024px) {
    /* Tablet specific styles */
    .n-theme-gallery-thumbnail {
        width: 70px;
        height: 70px;
        min-width: 70px;
    }
    
    .n-theme-gallery-thumbnails {
        width: 90px;
        max-height: calc((70px + 8px) * 5); /* Adjust for tablet */
    }
}

@media (max-width: 768px) {
    .n-theme-product-gallery {
        flex-direction: column-reverse;
    }
    
    .n-theme-gallery-thumbnails-wrapper {
        flex-direction: row;
        width: 100%;
    }
    
    .n-theme-gallery-thumbnails {
        width: 100%!important;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-right: 0;
        padding-bottom: 10px;
        max-height: none;
        max-width: 100%;
        gap: 8px;
    }
    
    /* Show limited items on mobile horizontal scroll */
    .n-theme-gallery-thumbnails[data-visible] {
        overflow-x: auto;
    }
    
    .n-theme-gallery-thumbnail {
        width: 60px;
        min-width: 60px;
        height: 60px;
    }
    
    /* Mobile thumbnail navigation arrows */
    .n-theme-gallery-thumb-nav {
        top: 50%!important;
        transform: translateY(-50%);
        display: none!important;
    }
    
    .n-theme-gallery-thumb-nav.prev {
        left: -10px;
    }
    
    .n-theme-gallery-thumb-nav.prev:before {
        transform: rotate(135deg)!important;
    }
    
    .n-theme-gallery-thumb-nav.next {
        right: -10px;
        left: auto;
    }
    
    .n-theme-gallery-thumb-nav.next:before {
        transform: rotate(-45deg)!important;
    }
    
    /* Keep vertical layout if specifically set */
    .mobile-layout-vertical .n-theme-product-gallery {
        flex-direction: row;
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumbnails-wrapper {
        flex-direction: column;
        width: auto;
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumbnails {
        width: 80px;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 10px;
        padding-bottom: 0;
        max-height: calc((60px + 6px) * 5); /* Adjust for mobile vertical */
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumb-nav.prev {
        top: -12px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumb-nav.prev:before {
        transform: rotate(-135deg);
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumb-nav.next {
        bottom: -12px;
        top: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .mobile-layout-vertical .n-theme-gallery-thumb-nav.next:before {
        transform: rotate(45deg);
    }
}

/* Elementor responsive overrides */
.elementor-widget-n_theme_vertical_gallery .n-theme-gallery-thumbnails {
    max-height: calc((80px + 10px) * var(--visible-thumbnails, 5));
}

@media (max-width: 1024px) {
    .elementor-widget-n_theme_vertical_gallery .n-theme-gallery-thumbnails {
        max-height: calc((70px + 8px) * var(--visible-thumbnails, 5));
    }
}

@media (max-width: 767px) {
    .elementor-widget-n_theme_vertical_gallery .n-theme-gallery-thumbnails {
        max-width: calc((60px + 8px) * var(--visible-thumbnails, 5));
    }
    
    .elementor-widget-n_theme_vertical_gallery.mobile-layout-vertical .n-theme-gallery-thumbnails {
        max-width: none;
        max-height: calc((60px + 6px) * var(--visible-thumbnails, 5));
    }
}