/* Ultra-optimized gallery styles */
.gallery-section {
    padding: 60px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.gallery-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    aspect-ratio: 4/3;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 30px 20px 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.project-name {
    display: block;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 5px;
}

.image-count {
    display: block;
    font-size: 14px;
    opacity: 0.9;
}

/* Minimalistic Modal Styles */
.gallery-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1001;
    backdrop-filter: blur(10px);
}

.gallery-modal .modal-content {
    position: relative;
    width: 95vw;
    max-width: 1200px;
    height: 95vh;
    margin: 2.5vh auto;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-modal .close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    color: #333;
    z-index: 10;
    transition: all 0.2s ease;
}

.gallery-modal .close-modal:hover {
    background: white;
    transform: scale(1.1);
}

.gallery-modal .modal-header {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}

.project-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: #333;
}

.project-location {
    font-size: 14px;
    color: #666;
}

.gallery-modal .main-image-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

.gallery-modal #modalMainImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-modal .nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    transition: all 0.2s ease;
    z-index: 5;
}

.gallery-modal .nav-btn:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.gallery-modal .prev-btn {
    left: 20px;
}

.gallery-modal .next-btn {
    right: 20px;
}

.gallery-modal .thumbnails-container {
    display: flex;
    gap: 10px;
    padding: 15px 30px;
    overflow-x: auto;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.gallery-modal .thumbnails-container::-webkit-scrollbar {
    height: 6px;
}

.gallery-modal .thumbnails-container::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-modal .thumbnails-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.gallery-modal .gallery-thumbnail {
    width: 80px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.gallery-modal .gallery-thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.gallery-modal .gallery-thumbnail.active {
    opacity: 1;
    border-color: #007bff;
    transform: scale(1.05);
}

.gallery-modal .gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-modal .image-counter {
    text-align: center;
    padding: 10px 30px;
    background: #f8f9fa;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-top: 1px solid #e9ecef;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
        margin: 30px 0;
    }
    
    .gallery-item {
        aspect-ratio: 3/2;
    }
    
    .modal-content {
        margin: 0;
        border-radius: 0;
    }
    
    .close-modal {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .project-title {
        font-size: 20px;
    }
    
    .nav-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .prev-btn {
        left: 15px;
    }
    
    .next-btn {
        right: 15px;
    }
    
    .thumbnails-container {
        padding: 12px 20px;
        gap: 8px;
    }
    
    .gallery-thumbnail {
        width: 70px;
        height: 50px;
    }
    
    .image-counter {
        padding: 8px 20px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .gallery-item {
        aspect-ratio: 4/3;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .gallery-thumbnail {
        width: 60px;
        height: 45px;
    }
}

/* Smooth transitions */
.gallery-modal {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-modal.show {
    opacity: 1;
}

/* Performance optimizations */
.gallery-item img,
.nav-btn,
.gallery-thumbnail {
    will-change: transform;
    contain: layout style paint;
}

/* GPU acceleration for smooth animations */
.gallery-item,
.gallery-modal,
.nav-btn,
.gallery-thumbnail {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-modal,
    .nav-btn,
    .gallery-thumbnail {
        transition: none;
        animation: none;
    }
    
    .gallery-item:hover {
        transform: none;
    }
    
    .gallery-item:hover img {
        transform: none;
    }
}
