/**
 * MrWin Gallery - Lightbox Styles
 * 
 * @package MrWin_Gallery
 */

/* =============================================================================
   LIGHTBOX OVERLAY
   ============================================================================= */

.mwpc-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mwpc-lightbox-overlay.active {
    display: flex;
}

.mwpc-lightbox-overlay.visible {
    opacity: 1;
}

/* Prevent body scroll when lightbox is open */
body.mwpc-lightbox-open {
    overflow: hidden;
}

/* =============================================================================
   LIGHTBOX CONTAINER
   ============================================================================= */

.mwpc-lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Image wrapper for proper arrow positioning */
.mwpc-lightbox-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =============================================================================
   MAIN IMAGE
   ============================================================================= */

.mwpc-lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mwpc-lightbox-image.loading {
    opacity: 0.5;
}

/* =============================================================================
   CLOSE BUTTON
   ============================================================================= */

.mwpc-lightbox-close {
    position: absolute;
    top: -50px;
    right: -5px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mwpc-lightbox-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mwpc-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.mwpc-lightbox-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* =============================================================================
   NAVIGATION ARROWS - IMAGE MODE (Default)
   ============================================================================= */

.mwpc-lightbox-nav {
    position: relative;
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
}

.mwpc-lightbox-nav svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mwpc-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.mwpc-lightbox-nav:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.mwpc-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mwpc-lightbox-prev {
    margin-right: 15px;
}

.mwpc-lightbox-next {
    margin-left: 15px;
}

/* =============================================================================
   NAVIGATION ARROWS - VIEWPORT MODE
   ============================================================================= */

.mwpc-lightbox-overlay.arrows-viewport .mwpc-lightbox-prev {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 0;
}

.mwpc-lightbox-overlay.arrows-viewport .mwpc-lightbox-next {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
}

/* =============================================================================
   CAPTION
   ============================================================================= */

.mwpc-lightbox-caption {
    margin-top: 15px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    color: white;
    text-align: center;
    max-width: 80%;
}

.mwpc-lightbox-caption-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.mwpc-lightbox-caption-text {
    font-size: 14px;
    opacity: 0.9;
}

/* =============================================================================
   COUNTER
   ============================================================================= */

.mwpc-lightbox-counter {
    position: absolute;
    top: -50px;
    left: -5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

/* Fade Animation (default) */
.mwpc-lightbox-overlay.animation-fade {
    transition: opacity 0.2s ease;
}

.mwpc-lightbox-overlay.animation-fade .mwpc-lightbox-container {
    transition: transform 0.2s ease;
}

/* Slide Animation */
.mwpc-lightbox-overlay.animation-slide .mwpc-lightbox-container {
    transform: translateY(30px);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.mwpc-lightbox-overlay.animation-slide.visible .mwpc-lightbox-container {
    transform: translateY(0);
}

/* Zoom Animation */
.mwpc-lightbox-overlay.animation-zoom .mwpc-lightbox-container {
    transform: scale(0.9);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.mwpc-lightbox-overlay.animation-zoom.visible .mwpc-lightbox-container {
    transform: scale(1);
}

/* No Animation */
.mwpc-lightbox-overlay.animation-none {
    transition: none;
}

.mwpc-lightbox-overlay.animation-none .mwpc-lightbox-container {
    transition: none;
}

/* Image transition between slides */
.mwpc-lightbox-image-transition {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.mwpc-lightbox-image-transition.visible {
    opacity: 1;
    transform: scale(1);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .mwpc-lightbox-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .mwpc-lightbox-image {
        max-height: 70vh;
    }
    
    .mwpc-lightbox-nav {
        width: 44px;
        height: 44px;
    }
    
    .mwpc-lightbox-nav svg {
        width: 20px;
        height: 20px;
    }
    
    .mwpc-lightbox-prev {
        margin-right: 10px;
    }
    
    .mwpc-lightbox-next {
        margin-left: 10px;
    }
    
    /* Viewport mode adjustments for mobile */
    .mwpc-lightbox-overlay.arrows-viewport .mwpc-lightbox-prev {
        left: 10px;
    }
    
    .mwpc-lightbox-overlay.arrows-viewport .mwpc-lightbox-next {
        right: 10px;
    }
    
    .mwpc-lightbox-close {
        top: -35px;
        right: -5px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
    
    .mwpc-lightbox-counter {
        top: -35px;
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .mwpc-lightbox-caption {
        max-width: 95%;
        padding: 8px 15px;
    }
    
    .mwpc-lightbox-caption-title {
        font-size: 14px;
    }
    
    .mwpc-lightbox-caption-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* On very small screens, reduce arrow spacing */
    .mwpc-lightbox-prev {
        margin-right: 5px;
    }
    
    .mwpc-lightbox-next {
        margin-left: 5px;
    }
    
    .mwpc-lightbox-nav {
        background: rgba(0, 0, 0, 0.5);
        width: 40px;
        height: 40px;
    }
    
    .mwpc-lightbox-nav svg {
        width: 18px;
        height: 18px;
    }
}

/* =============================================================================
   LOADING STATE
   ============================================================================= */

.mwpc-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: mwpc-lightbox-spin 0.8s linear infinite;
}

@keyframes mwpc-lightbox-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* =============================================================================
   VIDEO SUPPORT
   ============================================================================= */

/* Content wrapper for image and video */
.mwpc-lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video container */
.mwpc-lightbox-video-container {
    display: none;
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    /* Flex properties for centering content when valid */
    justify-content: center;
    align-items: center;
}

/* Video thumbnail */
.mwpc-lightbox-video-thumb {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mwpc-lightbox-video-thumb-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* Placeholder for videos without thumbnails */
.mwpc-lightbox-video-placeholder {
    width: 640px;
    height: 360px;
    max-width: 90vw;
    max-height: 80vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Video extension text in placeholder */
.mwpc-lightbox-video-ext {
    font-size: 2.5rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Play overlay */
.mwpc-lightbox-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.mwpc-lightbox-video-thumb:hover .mwpc-lightbox-play-overlay {
    background: rgba(0, 0, 0, 0.1);
}

/* Play button image */
.mwpc-lightbox-play-btn {
    width: 80px;
    height: 80px;
    transition: transform 0.2s ease;
}

.mwpc-lightbox-video-thumb:hover .mwpc-lightbox-play-btn {
    transform: scale(1.1);
}

/* Fallback play button */
.mwpc-lightbox-play-fallback {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #333;
    transition: transform 0.2s ease, background 0.2s ease;
}

.mwpc-lightbox-video-thumb:hover .mwpc-lightbox-play-fallback {
    transform: scale(1.1);
    background: #fff;
}

/* Video player (iframe or video element) */
.mwpc-lightbox-video-player {
    width: 80vw;
    height: 45vw;
    max-width: 1280px;
    max-height: 720px;
    border: none;
    border-radius: 4px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* Specific for self-hosted video elements to respect aspect ratio */
video.mwpc-lightbox-video-player {
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 80vh;
    background: #000;
}
