/* Universal Lightbox Styles - Cross-Platform Compatible */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Performance optimizations */
    will-change: opacity, visibility;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.lightbox.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.lightbox.closing {
    opacity: 0;
    visibility: hidden;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Premium glassy background effect */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.6) 75%,
        rgba(0, 0, 0, 0.8) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
    will-change: transform;
}

.lightbox-content.slide-left {
    transform: translateX(-100px);
    opacity: 0.5;
}

.lightbox-content.slide-right {
    transform: translateX(100px);
    opacity: 0.5;
}

.lightbox-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 80vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
    opacity: 0;
    /* Prevent image dragging */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    /* Prevent selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.lightbox-image.loaded {
    opacity: 1;
}

.lightbox-image.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 10;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.lightbox-caption {
    margin-top: 20px;
    padding: 15px 20px;
    /* High contrast background for readability */
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    text-align: center;
    border-radius: 12px;
    max-width: 100%;
    box-sizing: border-box;
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.lightbox-caption .image-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: capitalize;
    color: #ffffff !important;
    /* Maximum contrast for readability */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1),
                 -1px -1px 2px rgba(0, 0, 0, 1),
                 1px -1px 2px rgba(0, 0, 0, 1),
                 -1px 1px 2px rgba(0, 0, 0, 1);
}

.lightbox-caption .error-message {
    color: #ff6b6b;
    font-style: italic;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    /* High contrast glassy button */
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 20;
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1);
}

.lightbox-close:hover {
    background: linear-gradient(135deg,
        rgba(255, 107, 107, 0.4) 0%,
        rgba(255, 107, 107, 0.2) 50%,
        rgba(255, 0, 0, 0.3) 100%);
    border-color: rgba(255, 107, 107, 0.5);
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(255, 107, 107, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    /* High contrast glassy navigation buttons */
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 20;
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1);
}

.lightbox-nav:hover:not(:disabled) {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(0, 0, 0, 0.1) 100%);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 12px 40px rgba(255, 255, 255, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

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

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    /* Maximum contrast counter for all modes */
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: #ffffff !important;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8),
                inset 0 1px 0 rgba(255, 255, 255, 0.4),
                0 0 0 1px rgba(0, 0, 0, 1);
    /* Strong text shadow for maximum visibility */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1),
                 -1px -1px 2px rgba(0, 0, 0, 1),
                 1px -1px 2px rgba(0, 0, 0, 1),
                 -1px 1px 2px rgba(0, 0, 0, 1);
}

/* Dark mode support - Enhanced glassy effects */
.dark .lightbox-overlay {
    background: linear-gradient(135deg,
        rgba(0, 0, 0, 0.2) 0%,
        rgba(0, 0, 0, 0.4) 25%,
        rgba(0, 0, 0, 0.7) 50%,
        rgba(0, 0, 0, 0.85) 75%,
        rgba(0, 0, 0, 0.95) 100%);
}

.dark .lightbox-caption {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(0, 0, 0, 0.4) 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.dark .lightbox-close,
.dark .lightbox-nav,
.dark .lightbox-counter {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(0, 0, 0, 0.3) 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Mobile and tablet optimizations */
@media (max-width: 768px) {
    .lightbox-container {
        padding: 10px;
    }
    
    .lightbox-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .lightbox-image-container {
        max-height: 75vh;
    }
    
    .lightbox-close {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
        font-size: 1.3rem;
    }
    
    .lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .lightbox-prev {
        left: 15px;
    }
    
    .lightbox-next {
        right: 15px;
    }
    
    .lightbox-caption {
        margin-top: 15px;
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .lightbox-counter {
        top: 15px;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .lightbox-container {
        padding: 5px;
    }
    
    .lightbox-content {
        max-width: 98vw;
        max-height: 98vh;
    }
    
    .lightbox-image-container {
        max-height: 70vh;
    }
    
    .lightbox-close {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
        font-size: 1.2rem;
    }
    
    .lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-caption {
        margin-top: 10px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .lightbox-counter {
        top: 10px;
        font-size: 0.75rem;
        padding: 5px 10px;
    }
}

/* TV and large screen optimizations */
@media (min-width: 1200px) {
    .lightbox-close {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .lightbox-nav {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .lightbox-caption {
        font-size: 1.2rem;
        padding: 20px 25px;
    }
    
    .lightbox-counter {
        font-size: 1rem;
        padding: 10px 20px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .lightbox-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .lightbox,
    .lightbox-content,
    .lightbox-image,
    .lightbox-close,
    .lightbox-nav {
        transition: none;
    }
    
    .loader-spinner {
        animation: none;
    }
}

/* Focus styles for keyboard navigation */
.lightbox-close:focus,
.lightbox-nav:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

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