/* 2sit Product Gallery Widget Styles */

.tosit-product-gallery {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 100%;
}

/* Hide desktop gallery on mobile - use mobile widget instead */
@media (max-width: 768px) {
    .tosit-product-gallery {
        display: none !important;
    }
}

/* Default sizing when no Elementor controls are applied */
.tosit-product-gallery .tosit-gallery-thumbnails-wrapper {
    width: 120px;
}

.tosit-product-gallery .tosit-gallery-thumbnails {
    padding: 10px;
    padding-top: 20px;
    padding-bottom: 20px;
}

.tosit-product-gallery .tosit-gallery-main {
    width: calc(100% - 120px - 20px); /* Account for width + gap */
}

.tosit-product-gallery.vertical-layout {
    flex-direction: column;
}

.tosit-product-gallery.horizontal-layout {
    flex-direction: row;
    align-items: stretch;
}

.tosit-product-gallery.thumbnails-right {
    flex-direction: row-reverse;
}

/* Main Image Container */
.tosit-gallery-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    aspect-ratio: 689 / 516; /* Custom aspect ratio 689:516 */
    background-color: #ffffff;
    border-radius: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.tosit-gallery-main img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    transition: opacity 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Navigation Arrows */
.tosit-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    color: currentColor;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 1;
    visibility: visible;
    padding: 0px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.tosit-gallery-nav:hover {
    transform: translateY(-50%) scale(1.1);
    background: none;
}

.tosit-gallery-nav:focus {
    background: none;
}

.tosit-gallery-nav.prev {
    left: 20px;
}

.tosit-gallery-nav.next {
    right: 20px;
}

.tosit-gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tosit-gallery-nav:disabled:hover {
    transform: translateY(-50%);
    opacity: 0.3;
}

.tosit-gallery-nav svg {
    width: 24px;
    height: 24px;
    stroke: black;
}

/* Thumbnails Wrapper */
.tosit-gallery-thumbnails-wrapper {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%; /* Stretch to match main image height */
    position: relative;
}

/* Thumbnails Container */
.tosit-gallery-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.tosit-gallery-thumbnails::-webkit-scrollbar {
    display: none; /* WebKit */
}

/* Scroll Indicator Arrows - Fixed Position */
.tosit-scroll-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    opacity: 0.8;
}

.tosit-scroll-indicator:hover {
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.tosit-scroll-indicator.up {
    top: -15px;
}

.tosit-scroll-indicator.down {
    bottom: -15px;
}

.tosit-scroll-indicator.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tosit-scroll-indicator.disabled:hover {
    transform: translateX(-50%);
    opacity: 0.3;
}

.tosit-scroll-indicator svg {
    width: 16px;
    height: 16px;
    stroke: #333;
    stroke-width: 2;
}

/* Rotate chevrons to point up/down */
.tosit-scroll-indicator.up svg {
    transform: rotate(-90deg);
}

.tosit-scroll-indicator.down svg {
    transform: rotate(90deg);
}

/* Horizontal thumbnails (bottom position) */
.tosit-gallery-thumbnails.horizontal {
    flex-direction: row;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

.tosit-gallery-thumbnails.horizontal .tosit-gallery-thumbnail {
    width: 105px;
    height: calc(105px * 516 / 689); /* Maintain aspect ratio for horizontal thumbnails */
}

/* Hide scroll indicators for horizontal thumbnails (they don't use wrapper) */
.tosit-gallery-thumbnails.horizontal .tosit-scroll-indicator {
    display: none;
}

/* Individual Thumbnail */
.tosit-gallery-thumbnail {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    aspect-ratio: 689 / 516; /* Match main image aspect ratio */
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
}

/* Variation thumbnails inherit the same styling as regular thumbnails */

.tosit-gallery-thumbnail img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.tosit-gallery-thumbnail:hover img,
.tosit-gallery-thumbnail.active img {
    opacity: 1;
}

.tosit-gallery-thumbnail:hover,
.tosit-gallery-thumbnail.active {
    border-color: #007cba;
    transform: scale(1.05);
}

.tosit-gallery-thumbnail.active {
    border-color: #007cba;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 124, 186, 0.3);
}

/* Fast and Smooth Transitions */
.tosit-gallery-main img {
    transition: opacity 0.075s ease-out;
}

.tosit-gallery-main.loading img {
    opacity: 0.95; /* Reduced opacity change to minimize visual flash */
}

/* Autoplay States */
.tosit-product-gallery[data-autoplay="true"] {
    position: relative;
}

.tosit-product-gallery[data-autoplay="true"]:hover .tosit-gallery-nav {
    opacity: 1;
    visibility: visible;
}


/* Smooth thumbnail transitions during autoplay */
.tosit-gallery-thumbnail {
    transition: all 0.3s ease, border-color 0.2s ease, transform 0.2s ease;
}


/* Preview Mode (Editor) */
.tosit-product-gallery.preview {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 4px;
    color: #6c757d;
    font-style: italic;
}


/* Accessibility */
.tosit-gallery-thumbnail:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.tosit-gallery-thumbnail:focus img {
    opacity: 1;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tosit-gallery-thumbnail img {
        border-width: 3px;
    }
    
    .tosit-gallery-thumbnail.active img {
        border-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tosit-gallery-thumbnail img,
    .tosit-gallery-main img,
    .tosit-gallery-thumbnail {
        transition: none;
    }
    
    .tosit-gallery-thumbnail:hover img,
    .tosit-gallery-thumbnail.active img {
        transform: none;
    }
    
    .tosit-gallery-main.loading::after {
        animation: none;
    }
}
