/* Custom Lightbox Styles - Optimized */
.custom-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 999999;
    overflow: hidden;
}

.custom-lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.custom-lightbox-overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.custom-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    z-index: 2;
    pointer-events: none;
}

.custom-lightbox-container > * {
    pointer-events: auto;
}

.custom-lightbox-image-wrapper {
    position: relative;
    width: auto;
    max-width: 100%;
    max-height: calc(100% - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    overflow: hidden;
}

.custom-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    margin: 0 auto;
}

/* Navigation & Close Buttons */
.custom-lightbox-nav,
.custom-lightbox-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    color: #fff;
}

.custom-lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: transparent;
    border: none;
}

.custom-lightbox-nav svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
}

.custom-lightbox-nav.prev {
    left: 30px;
}

.custom-lightbox-nav.next {
    right: 30px;
}

.custom-lightbox-nav:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

.custom-lightbox-close {
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);
    z-index: 1001;
}

.custom-lightbox-close svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}

.custom-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Thumbnails */
.custom-lightbox-thumbnails-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.98) 0%, rgba(0, 0, 0, 0.9) 40%, rgba(0, 0, 0, 0.7) 70%, transparent 100%);
    padding: 10px 0;
    overflow: hidden;
    z-index: 1000;
}

.custom-lightbox-thumbnails {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 30px;
    height: 100%;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
}

.custom-lightbox-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.custom-lightbox-thumbnails::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.custom-lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
}

.custom-lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}

.custom-lightbox-thumbnail {
    min-width: 70px;
    width: 70px;
    height: 70px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.custom-lightbox-thumbnail:hover {
    opacity: 0.85;
    border-color: rgba(255, 255, 255, 0.4);
}

.custom-lightbox-thumbnail.active {
    border-color: #fff;
    opacity: 1;
    z-index: 10;
}

.custom-lightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    display: block;
}

/* Loading */
.custom-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 999;
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    inset: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite reverse;
}

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

/* Body scroll lock */
body.lightbox-open {
    overflow: hidden;
    padding-right: 0 !important;
}

/* Global box-sizing */
.custom-lightbox * {
    box-sizing: border-box;
}

/* Accessibility */
.custom-lightbox-nav:focus,
.custom-lightbox-close:focus {
    outline: 3px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .custom-lightbox-container {
        padding: 10px;
    }
    
    .custom-lightbox-nav {
        width: 50px;
        height: 50px;
    }
    
    .custom-lightbox-nav svg {
        width: 24px;
        height: 24px;
    }
    
    .custom-lightbox-nav.prev {
        left: 15px;
    }
    
    .custom-lightbox-nav.next {
        right: 15px;
    }
    
    .custom-lightbox-close {
        width: 44px;
        height: 44px;
        top: 15px;
        right: 15px;
    }
    
    .custom-lightbox-close svg {
        width: 20px;
        height: 20px;
    }
    
    .custom-lightbox-thumbnails-wrapper {
        height: 80px;
        padding: 8px 0;
    }
    
    .custom-lightbox-thumbnails {
        padding: 0 20px;
        gap: 8px;
    }
    
    .custom-lightbox-thumbnail {
        min-width: 70px;
        width: 70px;
        height: 70px;
    }
    
    .custom-lightbox-image-wrapper {
        max-height: calc(100% - 100px);
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .custom-lightbox-nav {
        width: 44px;
        height: 44px;
    }
    
    .custom-lightbox-nav.prev {
        left: 10px;
    }
    
    .custom-lightbox-nav.next {
        right: 10px;
    }
    
    .custom-lightbox-thumbnail {
        min-width: 60px;
        width: 60px;
        height: 60px;
    }
    
    .custom-lightbox-thumbnails-wrapper {
        height: 70px;
        padding: 8px 0;
    }
    
    .custom-lightbox-image-wrapper {
        max-height: calc(100% - 90px);
    }
}
