/* WDM Product Gallery Styles */

.wdm-product-gallery {
    display: flex;
    gap: 15px;
    flex-direction: row;
    align-items: flex-start;
}

/* Thumbnail rail */
.wdm-gallery-thumbnails-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    flex: 0 0 96px;
    width: 96px;
}

.wdm-gallery-thumbnails {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    width: 92px;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.wdm-gallery-thumbnails::-webkit-scrollbar {
    display: none;
}

/* Main gallery display */
.wdm-gallery-main {
    flex: 1;
    min-width: 300px;
}

.wdm-gallery-display {
    position: relative;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.wdm-gallery-viewport {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    background: #fff;
}

.wdm-gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdm-gallery-item.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

.wdm-gallery-image {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    display: block;
    transform: translateZ(0);
}

.wdm-gallery-item.active .wdm-gallery-image {
    cursor: zoom-in;
}

.wdm-gallery-lightbox {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(12, 12, 12, 0.88);
    z-index: 99999;
}

.wdm-gallery-lightbox.is-open {
    display: flex;
}

.wdm-gallery-lightbox-stage {
    position: relative;
    width: min(92vw, 1200px);
    height: min(88vh, 900px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdm-gallery-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.wdm-gallery-lightbox-close,
.wdm-gallery-lightbox-prev,
.wdm-gallery-lightbox-next {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.wdm-gallery-lightbox-close {
    top: 20px;
    right: 24px;
}

.wdm-gallery-lightbox-prev {
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
}

.wdm-gallery-lightbox-next {
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
}

body.wdm-lightbox-open {
    overflow: hidden;
}

.wdm-gallery-preview-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdm-gallery-thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdm-gallery-thumbnail:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wdm-gallery-thumbnail.active {
    border-color: #000;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000;
}

.wdm-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Preview thumbnail styling */
.wdm-gallery-thumbnail-preview {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    position: relative;
}

.wdm-thumbnail-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-align: center;
    padding: 4px 8px;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 768px) {
    .wdm-product-gallery {
        flex-direction: column;
    }

    .wdm-gallery-thumbnails-rail {
        width: 100%;
        flex-direction: row;
        align-items: center;
    }

    .wdm-gallery-thumbnails {
        flex-direction: row;
        flex: 1;
        max-height: 100px;
        overflow-x: auto;
        overflow-y: hidden;
        width: auto;
    }

    .wdm-gallery-thumbnail {
        width: 70px;
        height: 70px;
        flex: 0 0 70px;
    }

    .wdm-gallery-main {
        width: 100%;
    }

    .apb-preview-stage {
        width: 85%;
        height: 85%;
    }
}

/* Album preview builder integration */
.apb-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apb-preview-stage {
    position: relative;
    width: 75%;
    height: 75%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apb-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
}

.apb-layer.is-visible {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.apb-layer-base {
    z-index: 1;
}

.apb-layer-texture {
    z-index: 2;
    mix-blend-mode: multiply;
}

.apb-layer-print {
    z-index: 3;
}
