/**
 * CP10 Listing Gallery Styles
 * Pottery Barn-style product gallery
 */

/* Reset and base styles */
.cp10-lg-gallery {
    display: flex;
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

.cp10-lg-gallery *,
.cp10-lg-gallery *::before,
.cp10-lg-gallery *::after {
    box-sizing: border-box;
}

/* Layout variations */
.cp10-lg-layout-vertical-left {
    flex-direction: row;
}

.cp10-lg-layout-vertical-right {
    flex-direction: row-reverse;
}

.cp10-lg-layout-horizontal-top {
    flex-direction: column;
}

.cp10-lg-layout-horizontal-bottom {
    flex-direction: column-reverse;
}

/* Main image wrapper */
.cp10-lg-main-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

/* Main image container */
.cp10-lg-main-image {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.cp10-lg-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cp10-lg-slide.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

.cp10-lg-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Zoom functionality */
.cp10-lg-zoom-enabled .cp10-lg-main-image {
    overflow: hidden;
}

.cp10-lg-zoom-enabled .cp10-lg-slide.active img {
    transition: transform 0.15s ease-out;
    transform-origin: center center;
}

.cp10-lg-zoom-enabled .cp10-lg-main-image.zooming .cp10-lg-slide.active img {
    cursor: zoom-in;
}

/* Expand button */
.cp10-lg-expand-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cp10-lg-expand-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

.cp10-lg-expand-btn svg {
    width: 20px;
    height: 20px;
    color: #333;
}

/* Main image navigation arrows */
.cp10-lg-main-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
}

.cp10-lg-main-wrapper:hover .cp10-lg-main-nav {
    opacity: 1;
}

.cp10-lg-main-prev {
    left: 15px;
}

.cp10-lg-main-next {
    right: 15px;
}

.cp10-lg-main-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.cp10-lg-main-nav svg {
    width: 24px;
    height: 24px;
    color: #333;
}

/* Thumbnails container */
.cp10-lg-thumbnails {
    display: flex;
    position: relative;
    flex-shrink: 0;
}

.cp10-lg-thumbnails.vertical {
    flex-direction: column;
    width: 100px;
}

.cp10-lg-thumbnails.horizontal {
    flex-direction: row;
    height: 100px;
    width: 100%;
}

/* Thumbnails wrapper (scrollable area) */
.cp10-lg-thumbs-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.cp10-lg-thumbs-track {
    display: flex;
    transition: transform 0.3s ease;
}

.cp10-lg-thumbnails.vertical .cp10-lg-thumbs-track {
    flex-direction: column;
}

.cp10-lg-thumbnails.horizontal .cp10-lg-thumbs-track {
    flex-direction: row;
}

/* Individual thumbnail */
.cp10-lg-thumb {
    flex-shrink: 0;
    padding: 0;
    border: 2px solid transparent;
    background: #f0f0f0;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.cp10-lg-thumbnails.vertical .cp10-lg-thumb {
    width: 100%;
    aspect-ratio: 1;
}

.cp10-lg-thumbnails.horizontal .cp10-lg-thumb {
    height: 100%;
    aspect-ratio: 1;
}

.cp10-lg-thumb:hover {
    opacity: 0.9;
}

.cp10-lg-thumb.active {
    opacity: 1;
    border-color: #333;
}

.cp10-lg-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Thumbnail navigation buttons */
.cp10-lg-nav-btn {
    flex-shrink: 0;
    width: 100%;
    height: 30px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cp10-lg-thumbnails.horizontal .cp10-lg-nav-btn {
    width: 30px;
    height: 100%;
}

.cp10-lg-nav-btn:hover {
    background: #f5f5f5;
}

.cp10-lg-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cp10-lg-nav-btn svg {
    width: 16px;
    height: 16px;
    color: #333;
}

/* Lightbox styles */
.cp10-lg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cp10-lg-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.cp10-lg-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
}

.cp10-lg-lightbox-content {
    position: relative;
    width: 90%;
    height: 90%;
    max-width: 1400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cp10-lg-lightbox-slides {
    width: 100%;
    height: 100%;
    position: relative;
}

.cp10-lg-lightbox-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cp10-lg-lightbox-slide.active {
    opacity: 1;
    visibility: visible;
}

.cp10-lg-lightbox-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cp10-lg-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.cp10-lg-lightbox-close:hover {
    transform: scale(1.1);
}

.cp10-lg-lightbox-close svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.cp10-lg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cp10-lg-lightbox-prev {
    left: -70px;
}

.cp10-lg-lightbox-next {
    right: -70px;
}

.cp10-lg-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cp10-lg-lightbox-nav svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

.cp10-lg-lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* No images fallback */
.cp10-lg-no-images {
    padding: 40px;
    text-align: center;
    color: #666;
    background: #f8f8f8;
    border-radius: 8px;
}

/* Responsive styles */
@media (max-width: 768px) {
    .cp10-lg-layout-vertical-left,
    .cp10-lg-layout-vertical-right {
        flex-direction: column-reverse;
    }

    .cp10-lg-thumbnails.vertical {
        flex-direction: row;
        width: 100%;
        height: 80px;
    }

    .cp10-lg-thumbnails.vertical .cp10-lg-thumbs-track {
        flex-direction: row;
    }

    .cp10-lg-thumbnails.vertical .cp10-lg-thumb {
        width: auto;
        height: 100%;
    }

    .cp10-lg-thumbnails.vertical .cp10-lg-nav-btn {
        width: 30px;
        height: 100%;
    }

    .cp10-lg-gallery {
        height: auto !important;
    }

    .cp10-lg-main-wrapper {
        aspect-ratio: 1;
    }

    .cp10-lg-main-nav {
        opacity: 1;
        width: 36px;
        height: 36px;
    }

    .cp10-lg-main-prev {
        left: 10px;
    }

    .cp10-lg-main-next {
        right: 10px;
    }

    .cp10-lg-lightbox-prev {
        left: 10px;
    }

    .cp10-lg-lightbox-next {
        right: 10px;
    }

    .cp10-lg-lightbox-close {
        top: 10px;
        right: 10px;
    }

    .cp10-lg-lightbox-counter {
        bottom: 20px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .cp10-lg-main-nav {
        opacity: 1;
    }

    .cp10-lg-thumb:hover {
        opacity: 0.6;
    }

    .cp10-lg-thumb.active:hover {
        opacity: 1;
    }
}

/* Animation for slide transition */
.cp10-lg-gallery[data-transition="slide"] .cp10-lg-slide {
    transform: translateX(100%);
    opacity: 1;
    visibility: visible;
}

.cp10-lg-gallery[data-transition="slide"] .cp10-lg-slide.active {
    transform: translateX(0);
}

.cp10-lg-gallery[data-transition="slide"] .cp10-lg-slide.prev {
    transform: translateX(-100%);
}

/* Preloader for images */
.cp10-lg-slide.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f0f0f0;
    border-top-color: #333;
    border-radius: 50%;
    animation: cp10-lg-spin 0.8s linear infinite;
}

@keyframes cp10-lg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Image counter badge */
.cp10-lg-image-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 5;
}

/* Swipe indicator for mobile */
.cp10-lg-swipe-hint {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cp10-lg-gallery.show-hint .cp10-lg-swipe-hint {
    opacity: 1;
}
