/* ==========================================================================
   Lightbox Component Styles
   ========================================================================== */

/* Lightbox Container */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Lightbox Controls */
.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2001;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

/* Hide navigation buttons on mobile */
@media (max-width: 768px) {
    .lightbox-prev,
    .lightbox-next {
        display: none;
    }
}

/* Lightbox Content */
.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 0.5rem;
    transition: transform 0.3s ease, opacity 0.3s ease;
    cursor: zoom-in;
}

#lightbox-image.loading {
    opacity: 0;
}

#lightbox-image:not(.loading) {
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Lightbox Caption */
.lightbox-caption {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    text-align: center;
    max-width: 600px;
}

/* Lightbox Thumbnails */
.lightbox-thumbnails {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 0.5rem;
    max-width: 90vw;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.lightbox-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    padding: 0;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 0.375rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.lightbox-thumb:hover {
    opacity: 1;
    transform: scale(1.05);
}

.lightbox-thumb.active {
    opacity: 1;
    border-color: #2563eb;
}

.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 100vw;
        max-height: 90vh;
    }

    #lightbox-image {
        max-height: 60vh;
        border-radius: 0;
    }

    .lightbox-caption {
        margin: 1rem;
        font-size: 0.8125rem;
    }

    .lightbox-thumbnails {
        bottom: 1rem;
        gap: 0.375rem;
        padding: 0.375rem;
    }

    .lightbox-thumb {
        width: 50px;
        height: 50px;
    }

    .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 40px;
        height: 40px;
    }
}

/* Desktop Enhancements */
@media (min-width: 1024px) {
    #lightbox-image {
        max-height: 85vh;
        cursor: zoom-in;
    }

    #lightbox-image.zoomed {
        max-width: none;
        max-height: none;
        cursor: zoom-out;
        transform: scale(2);
    }

    .lightbox-thumbnails {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .lightbox-thumb {
        width: 80px;
        height: 80px;
    }
}

/* Loading Animation */
.lightbox.active #lightbox-image.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Keyboard Focus Styles */
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus,
.lightbox-thumb:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.lightbox-close:focus:not(:focus-visible),
.lightbox-prev:focus:not(:focus-visible),
.lightbox-next:focus:not(:focus-visible),
.lightbox-thumb:focus:not(:focus-visible) {
    outline: none;
}

/* Touch Gestures Indicator */
@media (hover: none) {
    .lightbox.active::after {
        content: 'Swipe to navigate';
        position: absolute;
        bottom: 8rem;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.5rem 1rem;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 2rem;
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.75rem;
        animation: fadeInOut 3s ease;
        pointer-events: none;
    }

    @keyframes fadeInOut {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: 1;
        }
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .lightbox,
    #lightbox-image,
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next,
    .lightbox-thumb {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}