/* Enhanced Gallery Size for 4K Images */

/* Maximize gallery container usage */
.gallery-container {
    padding: 30px 20px 20px !important;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    overflow: hidden !important; /* Prevent scrolling */
    display: flex;
    flex-direction: column;
}

/* Reduce header space to give more room for images */
.gallery-header {
    padding: 10px 0 15px 0 !important;
    margin-bottom: 15px !important;
}

.gallery-title {
    font-size: 2rem !important;
    margin-bottom: 5px !important;
}

.gallery-description {
    font-size: 0.95rem !important;
    margin-bottom: 0 !important;
}

/* Maximize main image area while keeping thumbnails visible */
.gallery-content {
    gap: 15px !important;
    height: calc(100vh - 150px) !important; /* Account for header and thumbnails */
    max-height: calc(100vh - 150px) !important;
}

.gallery-main-image {
    min-height: 60vh !important;
    max-height: calc(100vh - 250px) !important; /* Leave room for header + thumbnails */
    padding: 10px !important;
    flex: 1;
}

/* Increase image size to showcase 4K detail */
.gallery-main-image img {
    max-width: 98% !important;
    max-height: 98% !important;
    transition: transform 0.3s ease;
}

/* Optimize thumbnail strip - ensure it's always visible with smooth scrolling */
.gallery-thumbnails {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important; /* Center when few images */
    padding: 10px 20px !important;
    gap: 8px !important;
    height: 90px !important;
    max-height: 90px !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-shrink: 0; /* Prevent thumbnails from shrinking */
    margin-bottom: 10px !important;
    scroll-behavior: smooth;
    position: relative;
    align-items: center !important;
    box-sizing: border-box !important;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* When scrollable (many images), align to start for better scrolling */
.gallery-thumbnails.has-overflow {
    justify-content: flex-start !important;
}

/* Change cursor when dragging */
.gallery-thumbnails.dragging {
    cursor: grabbing !important;
    scroll-behavior: auto !important; /* Disable smooth scroll during drag */
}

/* Prevent text selection and image dragging */
.gallery-thumbnails * {
    user-select: none !important;
    -webkit-user-drag: none !important;
    pointer-events: none !important;
}

/* But keep thumbnails clickable */
.gallery-thumbnail {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.gallery-thumbnails.dragging .gallery-thumbnail {
    cursor: grabbing !important;
}

/* Fade edges to show more content available - only when scrollable */
.gallery-thumbnails.has-overflow::before,
.gallery-thumbnails.has-overflow::after {
    content: '';
    position: absolute;
    top: 0;
    width: 30px;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: var(--show-edges, 1);
    transition: opacity 0.3s ease;
}

.gallery-thumbnails.has-overflow::before {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.6), transparent);
}

.gallery-thumbnails.has-overflow::after {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.6), transparent);
}

/* Hide scrollbar but keep functionality */
.gallery-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.gallery-thumbnail {
    width: 120px !important;
    height: 80px !important;
    flex-shrink: 0;
}

/* Larger images on bigger screens */
@media (min-width: 1920px) {
    .gallery-main-image {
        min-height: 65vh !important;
        max-height: calc(100vh - 230px) !important; /* Still leave room for thumbnails */
    }
    
    .gallery-main-image img {
        max-width: 99% !important;
        max-height: 99% !important;
    }
    
    .gallery-container {
        padding: 25px 15px 15px !important;
    }
}

/* 4K screens optimization */
@media (min-width: 2560px) {
    .gallery-main-image {
        min-height: 70vh !important;
        max-height: calc(100vh - 220px) !important; /* Adjust for larger thumbnails */
    }
    
    .gallery-thumbnail {
        width: 150px !important;
        height: 100px !important;
    }
    
    .gallery-thumbnails {
        height: 110px !important;
        max-height: 110px !important;
    }
}

/* Tablet adjustments */
@media (max-width: 1200px) {
    .gallery-main-image {
        min-height: 55vh !important;
        max-height: calc(100vh - 260px) !important;
    }
    
    .gallery-main-image img {
        max-width: 96% !important;
        max-height: 96% !important;
    }
}

/* Mobile optimization - still maximize space */
@media (max-width: 768px) {
    .gallery-container {
        padding: 20px 10px 10px !important;
    }
    
    .gallery-header {
        padding: 5px 0 10px 0 !important;
        margin-bottom: 10px !important;
    }
    
    .gallery-title {
        font-size: 1.5rem !important;
    }
    
    .gallery-description {
        display: none; /* Hide description on mobile to save space */
    }
    
    .gallery-main-image {
        min-height: 45vh !important;
        max-height: calc(100vh - 200px) !important; /* Account for mobile header + thumbnails */
        padding: 5px !important;
    }
    
    .gallery-main-image img {
        max-width: 100% !important;
        max-height: 100% !important;
    }
    
    .gallery-thumbnail {
        width: 80px !important;
        height: 60px !important;
    }
    
    .gallery-thumbnails {
        max-height: 70px !important;
    }
}

@media (max-width: 480px) {
    .gallery-main-image {
        min-height: 40vh !important;
        max-height: calc(100vh - 180px) !important; /* Ensure thumbnails are visible */
    }
    
    .gallery-close {
        width: 35px !important;
        height: 35px !important;
        top: 10px !important;
        right: 10px !important;
    }
}

/* Navigation buttons positioning for larger images */
.gallery-nav {
    background: rgba(0, 0, 0, 0.6) !important;
    width: 50px !important;
    height: 50px !important;
}

.gallery-nav:hover {
    background: rgba(0, 0, 0, 0.8) !important;
}

@media (max-width: 768px) {
    .gallery-nav {
        width: 40px !important;
        height: 40px !important;
    }
}

/* Full screen mode button (optional enhancement) */
.gallery-fullscreen-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.gallery-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Image quality enhancement */
.gallery-main-image img,
.gallery-thumbnail img {
    image-rendering: high-quality;
    image-rendering: -webkit-optimize-contrast;
    -ms-interpolation-mode: bicubic;
}