/**
 * Lightbox (PhotoSwipe) Customisations
 * Minimal styling to integrate PhotoSwipe with Bootstrap 5
 */

/* Thumbnail styling for lightbox items */
.lightbox-gallery {
    cursor: pointer;
    display: block;
    position: relative;
    text-decoration: none;
}

/* Override PhotoSwipe default styles to match Bootstrap theme */
.pswp__bg {
    background: rgba(0, 0, 0, 0.95);
}

/* Top bar styling - match navbar height */
.pswp__top-bar {
    background: rgba(0, 0, 0, 0.5) !important;
    height: 50px !important;
    padding: 0 !important;
}

/* Remove individual button backgrounds */
.pswp__icn {
    top: 9px !important;
}

/* Fix cropped prev/next arrows by adjusting their SVG positioning */
.pswp__button--arrow--prev .pswp__icn {
    top: 25px !important;
    left: 5px !important;
}

/* Fix cropped prev/next arrows by adjusting their SVG positioning */
.pswp__button--arrow--next .pswp__icn {
    top: 25px !important;
    right: 10px !important;
}

/* Remove individual button backgrounds */
.pswp__button {
    background: none !important;
    border: none !important;
    outline: none !important;
    border-radius: 0;
    transition: opacity 0.2s ease;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
}

.pswp__button:hover {
    background: none !important;
    opacity: 0.7;
}

.pswp__button:focus {
    outline: none !important;
}

/* Ensure SVG icons are white */
.pswp__button svg {
    fill: white;
    color: white;
}

.pswp__icn {
    fill: white !important;
    color: white !important;
}

/* Counter styling - adjust for new top bar */
.pswp__counter {
    background: none;
    border-radius: 0;
    padding: 0;
    margin: 0 0 0 20px;
    height: 50px;
    line-height: 50px;
    font-size: 0.9rem;
    color: white;
}

/* Hide download button when downloads are disabled */
.pswp__button.download-disabled {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* Loading indicator */
.pswp__preloader {
    color: var(--bs-primary, #0d6efd);
}

/* Ensure proper z-index layering */
.pswp {
    z-index: 1090;
    /* Above navbar (1080), below modals (1100) */
}

/* Mobile-specific fixes */
@media (max-width: 768px) {

    /* Force top bar to show on mobile */
    .pswp__top-bar {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Force arrows to show on mobile */
    .pswp__button--arrow {
        display: flex !important;
        opacity: 0.8 !important;
        visibility: visible !important;
    }

}

/* =====================================================
   Video Play Icon Overlay for Thumbnails
   ===================================================== */

/* Play icon overlay container */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

/* Play icon circle */
.video-play-icon {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Play triangle */
.video-play-icon::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.9);
    margin-left: 4px;
    /* Optical center adjustment */
}

/* Hover effect */
.lightbox-gallery:hover .video-play-icon,
.thumbnail-link:hover .video-play-icon {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Smaller play icon for compact layouts (masonry, justified) */
.file-item:not(.file-card-wrapper) .video-play-icon {
    width: 50px;
    height: 50px;
}

.file-item:not(.file-card-wrapper) .video-play-icon::after {
    border-width: 8px 0 8px 14px;
    margin-left: 3px;
}

/* =====================================================
   PhotoSwipe Video Slide Styling
   ===================================================== */

/* HTML content container (for custom content like videos) */
.pswp__html-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Video slide container */
.pswp__video-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 20px 20px;
    box-sizing: border-box;
}

/* Video element styling - constrain to viewport */
.pswp__video {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 100px);
    width: auto;
    height: auto;
    background: #000;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

/* Video controls - ensure they're visible */
.pswp__video::-webkit-media-controls {
    opacity: 1;
}

/* Responsive video sizing */
@media (max-width: 768px) {
    .pswp__video-slide {
        padding: 50px 10px 10px;
    }

    /* Smaller play icon on mobile */
    .video-play-icon {
        width: 50px;
        height: 50px;
    }

    .video-play-icon::after {
        border-width: 8px 0 8px 14px;
        margin-left: 3px;
    }
}