/**
 * Portfolio Filter Gallery - Lightbox Styles
 * 
 * @package Portfolio_Filter_Gallery
 * @version 2.0.0
 */

/* ==========================================================================
   Body Lock - Prevent layout shift when lightbox opens
   ========================================================================== */

body.pfg-lightbox-open {
    overflow: hidden !important;
    padding-right: var(--pfg-scrollbar-width, 0px) !important;
}

/* ==========================================================================
   Lightbox Container
   ========================================================================== */

.pfg-lightbox {
    --pfg-lb-bg: rgba(0, 0, 0, 0.95);
    --pfg-lb-text: #ffffff;
    --pfg-lb-accent: #3858e9;
    
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--pfg-lb-bg) !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* CSS isolation from theme */
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    line-height: 1.5 !important;
    color: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    text-align: center !important;
}

.pfg-lightbox *,
.pfg-lightbox *::before,
.pfg-lightbox *::after {
    box-sizing: border-box !important;
}

.pfg-lightbox--open {
    opacity: 1;
    visibility: visible;
}

.pfg-lightbox--loading .pfg-lightbox-content::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pfgLbSpin 0.8s linear infinite;
}

@keyframes pfgLbSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Lightbox Content
   ========================================================================== */

.pfg-lightbox-content {
    position: relative !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pfg-lightbox-image {
    display: block !important;
    max-width: 90vw !important;
    max-height: 85vh !important;
    object-fit: contain !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

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

/* Video container */
.pfg-lightbox-video {
    width: 90vw !important;
    max-width: 1200px !important;
    aspect-ratio: 16 / 9;
    background: #000 !important;
    border: none !important;
    border-radius: 0 !important;
}

.pfg-lightbox-video iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
}

/* ==========================================================================
   Caption - Isolated from theme styles
   ========================================================================== */

.pfg-lightbox-caption {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    text-align: center !important;
    color: #ffffff !important;
    padding: 20px 60px !important;
    margin: 0 !important;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 60%, transparent 100%) !important;
    z-index: 10 !important;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    line-height: 1.5 !important;
    width: 100% !important;
    max-width: none !important;
}

.pfg-lightbox--loaded .pfg-lightbox-caption {
    opacity: 1;
    transform: translateY(0);
}

.pfg-lightbox-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5) !important;
    color: #ffffff !important;
    text-align: center !important;
    line-height: 1.4 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    font-family: inherit !important;
    border: none !important;
    background: none !important;
}

.pfg-lightbox-description {
    font-size: 14px !important;
    font-weight: 400 !important;
    opacity: 0.9;
    margin: 0 auto !important;
    padding: 0 !important;
    max-width: 800px !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5) !important;
    color: #ffffff !important;
    text-align: center !important;
    line-height: 1.5 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    font-family: inherit !important;
    border: none !important;
    background: none !important;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.pfg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.pfg-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pfg-lightbox-nav:focus {
    outline: 2px solid var(--pfg-lb-accent);
    outline-offset: 2px;
}

.pfg-lightbox-nav--prev {
    left: 20px;
}

.pfg-lightbox-nav--next {
    right: 20px;
}

.pfg-lightbox-nav svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px;
    flex-shrink: 0;
}

/* ==========================================================================
   Close Button
   ========================================================================== */

.pfg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.pfg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pfg-lightbox-close:focus {
    outline: 2px solid var(--pfg-lb-accent);
    outline-offset: 2px;
}

.pfg-lightbox-close svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    flex-shrink: 0;
}

/* ==========================================================================
   Counter
   ========================================================================== */

.pfg-lightbox-counter {
    position: absolute;
    top: 25px;
    left: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    z-index: 10;
}

/* ==========================================================================
   Thumbnails Strip (optional)
   ========================================================================== */

.pfg-lightbox-thumbs {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    max-width: 80vw;
    overflow-x: auto;
}

.pfg-lightbox-thumb {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.pfg-lightbox-thumb:hover {
    opacity: 0.9;
}

.pfg-lightbox-thumb--active {
    opacity: 1;
    border-color: #fff;
}

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

/* ==========================================================================
   Mobile Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .pfg-lightbox-nav {
        width: 40px;
        height: 40px;
    }
    
    .pfg-lightbox-nav--prev {
        left: 10px;
    }
    
    .pfg-lightbox-nav--next {
        right: 10px;
    }
    
    .pfg-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .pfg-lightbox-thumbs {
        display: none;
    }
    
    .pfg-lightbox-caption {
        bottom: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
        padding: 30px 15px 15px;
    }
}

/* ==========================================================================
   Touch/Swipe support indicator
   ========================================================================== */

@media (pointer: coarse) {
    .pfg-lightbox-nav {
        opacity: 0.5;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.pfg-lightbox:focus {
    outline: none;
}

.pfg-lightbox[aria-hidden="true"] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .pfg-lightbox,
    .pfg-lightbox-image,
    .pfg-lightbox-nav,
    .pfg-lightbox-close {
        transition: none;
    }
    
    .pfg-lightbox--loading .pfg-lightbox-content::after {
        animation: none;
    }
}
