/**
 * Doors Starter - Product Gallery Widget Styles
 */

.ds-pg {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ds-pg--thumbs-top { flex-direction: column-reverse; }

.ds-pg--thumbs-right,
.ds-pg--thumbs-left {
    flex-direction: row;
    align-items: flex-start;
}

.ds-pg--thumbs-right .ds-pg-thumbs,
.ds-pg--thumbs-left .ds-pg-thumbs {
    flex-direction: column;
    flex-shrink: 0;
    width: 80px;
}

.ds-pg--thumbs-right { flex-direction: row-reverse; }
.ds-pg--thumbs-left  { flex-direction: row; }

.ds-pg-main-wrap {
    flex: 1;
    min-width: 0;
}

.ds-pg-main {
    position: relative;
    width: 100%;
    background: transparent;
    overflow: hidden;
}

/* Gallery mode: fixed height (set by widget) ensures all slides align */
.ds-pg--gallery .ds-pg-main {
    background: #f5f5f5;
}

.ds-pg-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease;
}

/* Single image mode: natural height, no absolute positioning, no crop */
.ds-pg--single .ds-pg-main {
    height: auto !important;
    background: transparent;
}

.ds-pg--single .ds-pg-slide {
    position: relative;
    inset: auto;
    opacity: 1;
    visibility: visible;
}

.ds-pg--single .ds-pg-main img {
    /* In single mode show the full image at natural ratio */
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.ds-pg-slide.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

/* Define primary color variable with fallback chain */
.ds-pg {
    --ds-primary: var(--ds-primary-color, var(--e-global-color-primary, #CCAD62));
}

.ds-pg-main img {
    width: 100%;
    height: 100%;
    /* Default: contain - shows full image without cropping (better for tall door images) */
    object-fit: contain;
    display: block;
}

.ds-pg-lightbox-trigger {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

/* Navigation arrows */
.ds-pg-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    z-index: 2;
    transition: background .2s, transform .2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ds-pg-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.05);
}

.ds-pg-prev { right: 12px; }
.ds-pg-next { left: 12px; }

/* RTL-safe positioning */
html:not([dir="rtl"]) .ds-pg-prev { left: 12px; right: auto; }
html:not([dir="rtl"]) .ds-pg-next { right: 12px; left: auto; }

/* Counter */
.ds-pg-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 2;
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   Thumbnails: uniform sizing + hidden scrollbar + stable layout
   ========================================================================== */

/* Thumbnails container - top/bottom positions */
.ds-pg-thumbs {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;             /* small padding for active border breathing room */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar - Firefox */
    scrollbar-width: none;
    /* Hide scrollbar - IE / old Edge */
    -ms-overflow-style: none;
}

/* Hide scrollbar - Webkit (Chrome, Safari, new Edge) */
.ds-pg-thumbs::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Each thumbnail: fixed-width flex item.
   Border + background reserved at all times to prevent layout shift on state change. */
.ds-pg-thumb {
    position: relative;
    flex: 0 0 calc((100% - 10px * (var(--ds-pg-thumb-count, 5) - 1)) / var(--ds-pg-thumb-count, 5));
    aspect-ratio: 1;
    overflow: hidden;
    /* Permanent transparent border so active state never adds height */
    border: 2px solid transparent !important;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    /* Override theme/elementor button bg (red on hover, etc.) */
    background: transparent !important;
    background-color: transparent !important;
    transition: border-color .2s, opacity .2s;
    opacity: 0.75;
    /* Prevent any transform that could shift surrounding thumbs */
}

/* Vertical thumbs layout (left/right position) */
.ds-pg--thumbs-right .ds-pg-thumbs,
.ds-pg--thumbs-left .ds-pg-thumbs {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 600px;
    padding: 0 2px;
}

.ds-pg--thumbs-right .ds-pg-thumb,
.ds-pg--thumbs-left .ds-pg-thumb {
    flex: 0 0 auto;
    width: 100%;
}

/* Hover state: light overlay (no red bg), no scale (prevents jumping) */
.ds-pg-thumb:hover,
.ds-pg-thumb:focus,
.ds-pg-thumb:focus-visible,
button.ds-pg-thumb:hover,
button.ds-pg-thumb:focus {
    opacity: 1;
    /* No transform - prevents jumping */
    transform: none !important;
    /* Override any theme/elementor button hover backgrounds */
    background: transparent !important;
    background-color: transparent !important;
}

.ds-pg-thumb:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    z-index: 1;
    border-radius: inherit;
}

/* Active state: brand primary color border (replaces transparent, no height change) */
.ds-pg-thumb.is-active {
    opacity: 1;
    border-color: var(--ds-primary, #CCAD62) !important;
}

.ds-pg-thumb.is-active::after { display: none; }

/* Focus state for keyboard nav */
.ds-pg-thumb:focus-visible {
    outline: 2px solid var(--ds-primary, #CCAD62);
    outline-offset: 2px;
}

/* Thumb image: contain by default so tall door images aren't cropped */
.ds-pg-thumb img,
button.ds-pg-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: transparent;
    display: block;
    /* Reset any theme/Elementor cropping/borders */
    border-radius: 0;
    margin: 0;
    padding: 0;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Placeholder */
.ds-pg--placeholder .ds-pg-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.ds-pg-placeholder-content {
    opacity: 0.5;
}

/* Mobile */
@media (max-width: 767px) {
    .ds-pg--thumbs-right,
    .ds-pg--thumbs-left {
        flex-direction: column;
    }
    
    .ds-pg--thumbs-right .ds-pg-thumbs,
    .ds-pg--thumbs-left .ds-pg-thumbs {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        width: 100%;
    }
    
    .ds-pg--thumbs-right .ds-pg-thumb,
    .ds-pg--thumbs-left .ds-pg-thumb {
        width: auto;
    }
    
    .ds-pg-nav {
        width: 36px;
        height: 36px;
    }
}
