/**
 * Gallery Lightbox Styles
 * Full-size image viewing with navigation and lightbox functionality
 */

/* Lightbox Container */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-lightbox.active {
    opacity: 1;
}

/* Backdrop */
.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

/* Lightbox Content */
.lightbox-content {
    position: relative;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Image Container */
.lightbox-image-container {
    position: relative;
    max-width: 1440px;
    max-height: 960px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: calc(100% - 2em);
}

/* Navigation Buttons - Matching Slider Style */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 130px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    z-index: 20;
    opacity: 1;
}

.lightbox-nav:hover {
    opacity: 0.8;
}

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

.lightbox-nav-prev {
    left: 30px;
}

.lightbox-nav-next {
    right: 30px;
}

/* Arrow icons - using the same images as slider */
.lightbox-nav-prev::before {
    content: '';
    background-image: url('/wp-content/uploads/HD_Slider-Arrow-left.png');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 100%;
    height: 100%;
    display: block;
}

.lightbox-nav-next::before {
    content: '';
    background-image: url('/wp-content/uploads/HD_Slider-Arrow-right.png');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 100%;
    height: 100%;
    display: block;
}

/* Close Button */
.lightbox-close {
    position: fixed;
    top: 30px;
    right: 30px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    opacity: 0.65;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    font-size: 45px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9999;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Thumbnails */
.lightbox-thumbnails {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    max-width: 100%;
    overflow-x: auto;
    padding: 10px 0;
}

.lightbox-thumbnail {
    width: 80px;
    height: 60px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.lightbox-thumbnail:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.lightbox-thumbnail.active {
    border-color: white;
    transform: scale(1.1);
}

/* Counter */
.lightbox-counter {
    position: absolute;
    bottom: -50px;
    right: 0;
    color: white;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 0;
    font-weight: 500;
    z-index: 20;
}

/* Responsive Design */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .lightbox-nav {
        width: 40px;
        height: 100px;
    }
    
    .lightbox-nav-prev {
        left: 20px;
    }
    
    .lightbox-nav-next {
        right: 20px;
    }
    
    .lightbox-close {
        top: 20px;
        left: 20px;
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
    
    .lightbox-thumbnail {
        width: 60px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .lightbox-nav {
        width: 40px;
        height: 80px;
    }
    
    .lightbox-nav-prev {
        left: 15px;
    }
    
    .lightbox-nav-next {
        right: 15px;
    }
    
    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .lightbox-thumbnail {
        width: 50px;
        height: 38px;
    }
    
    .lightbox-counter {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Loading State */
.lightbox-image.loading {
    opacity: 0.7;
}

.lightbox-image.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Accessibility Improvements */
.lightbox-nav:focus-visible,
.lightbox-close:focus-visible,
.lightbox-thumbnail:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .lightbox-nav,
    .lightbox-close {
        background: black;
        border: 2px solid white;
    }
    
    .lightbox-nav:hover,
    .lightbox-close:hover {
        background: white;
        color: black;
    }
    
    .lightbox-thumbnail.active {
        border-color: white;
        box-shadow: 0 0 0 2px white;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-lightbox,
    .lightbox-nav,
    .lightbox-close,
    .lightbox-thumbnail {
        transition: none;
    }
    
    .lightbox-nav:hover {
        transform: translateY(-50%);
    }
    
    .lightbox-close:hover,
    .lightbox-thumbnail:hover {
        transform: scale(1);
    }
}

/* Print Styles */
@media print {
    .gallery-lightbox {
        display: none !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .lightbox-nav,
    .lightbox-close {
        min-width: 44px;
        min-height: 44px;
    }
    
    .lightbox-thumbnail {
        min-width: 44px;
        min-height: 44px;
    }
}

/* MagnificPopup Compatibility */
.mfp-container {
    z-index: 10000;
}

.mfp-bg {
    z-index: 9999;
}

/* Ensure RoyalSlider images work properly with MagnificPopup */
.royalSlider img {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.royalSlider img:hover {
    opacity: 0.9;
}

/* Prevent conflicts between our lightbox and MagnificPopup */
.gallery-lightbox {
    z-index: 9998;
}


