/* ========================================
   COMPLETE GALLERY PAGE STYLES
   Replace your existing gallery.css with this
======================================== */

.gallery-page-section {
    min-height: 100vh;
    padding: 140px 5% 80px;
    background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    overflow: hidden; /* Prevent overflow */
    position: relative; /* Contain absolute children */
}

/* ========================================
   GALLERY HEADER
======================================== */
.gallery-header {
    text-align: center;
    margin-bottom: 60px;
    color: white;
}

.gallery-header h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    margin-bottom: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #a8b3cf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gallery-header p {
    font-size: 16px;
    line-height: 1.8;
    opacity: 0.9;
    max-width: 800px;
    margin: 0 auto;
}

/* ========================================
   CATEGORY FILTER
======================================== */
.gallery-filter {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 60px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.filter-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
}

.filter-btn i {
    font-size: 16px;
}

/* ========================================
   FEATURED CAROUSEL
======================================== */
.featured-section {
    margin-bottom: 60px;
}

.featured-section h2 {
    color: white;
    font-size: 2rem;
    margin-bottom: 25px;
    font-weight: 600;
}

.featured-carousel {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 30px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    cursor: grab;
    user-select: none;
}

.featured-carousel:active {
    cursor: grabbing;
}

.featured-carousel::-webkit-scrollbar {
    height: 8px;
}

.featured-carousel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.featured-carousel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.featured-carousel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.featured-item {
    flex: 0 0 180px;
    height: 180px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.featured-item:hover {
    transform: scale(1.08);
    border-color: #4f46e5;
    box-shadow: 0 15px 40px rgba(79, 70, 229, 0.5);
}

.featured-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   MASONRY GALLERY GRID - FIXED NO OVERLAP
======================================== */
.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding-bottom: 60px; /* Space before next section */
}

.gallery-section-title {
    color: white;
    font-size: 2rem;
    margin-bottom: 30px;
    font-weight: 600;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Fixed 4 columns */
    grid-auto-rows: 250px; /* Fixed row height */
    gap: 20px;
    grid-auto-flow: dense; /* Fill gaps automatically */
    margin-bottom: 40px; /* Space before load more button */
}

/* Gallery Item */
.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    
    /* Default: Takes 1 column, 1 row */
    grid-column: span 1;
    grid-row: span 1;
    
    /* Ensure items stay within bounds */
    min-height: 0;
    min-width: 0;
}

/* Size Variations - Auto Applied */
.gallery-item-large {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item-wide {
    grid-column: span 2;
    grid-row: span 1;
}

.gallery-item-tall {
    grid-column: span 1;
    grid-row: span 2;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        rgba(0, 0, 0, 0.8) 100%
    );
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 25px;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.overlay-content {
    color: white;
}

.overlay-content h3 {
    font-size: 1.25rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.overlay-content p {
    font-size: 14px;
    opacity: 0.9;
}

/* Load More Button */
.gallery-load-more {
    text-align: center;
    margin: 40px 0 60px 0; /* Space above and below */
    padding: 20px 0;
}

.load-more-btn {
    padding: 16px 40px;
    font-size: 16px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.load-more-btn:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #6b7280;
}

/* ========================================
   FULLSCREEN POPUP VIEWER
======================================== */
.gallery-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    animation: fadeIn 0.3s ease;
}

.gallery-popup.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.popup-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 60px;
}

.popup-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.popup-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-prev {
    left: 30px;
}

.popup-next {
    right: 30px;
}

.popup-nav:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    transform: translateY(-50%) scale(1.1);
}

.popup-image-container {
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#popupImage {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.4s ease;
}

.popup-info {
    text-align: center;
    color: white;
    margin-top: 25px;
}

.popup-info h3 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.popup-info p {
    font-size: 16px;
    opacity: 0.8;
}

.popup-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */
@media (max-width: 1400px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr); /* Keep 4 columns */
        grid-auto-rows: 220px;
    }
}

@media (max-width: 1024px) {
    .gallery-page-section {
        padding: 120px 4% 60px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on tablets */
        grid-auto-rows: 200px;
    }
    
    .popup-content {
        padding: 60px 40px;
    }
    
    .popup-nav {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .featured-item {
        flex: 0 0 160px;
        height: 160px;
    }
}

@media (max-width: 768px) {
    .gallery-header h1 {
        font-size: 2.5rem;
    }
    
    .gallery-filter {
        gap: 10px;
    }
    
    .filter-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
        grid-auto-rows: 180px;
        gap: 15px;
    }
    
    /* Simplify on mobile - all items become 1x1 or 2x1 max */
    .gallery-item-large {
        grid-column: span 2;
        grid-row: span 1; /* Reduced from 2x2 to 2x1 */
    }
    
    .gallery-item-wide {
        grid-column: span 2;
        grid-row: span 1;
    }
    
    .gallery-item-tall {
        grid-column: span 1;
        grid-row: span 2; /* Keep tall on mobile */
    }
    
    .featured-item {
        flex: 0 0 140px;
        height: 140px;
    }
    
    .popup-content {
        padding: 40px 20px;
    }
    
    .popup-close {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    
    .popup-nav {
        width: 45px;
        height: 45px;
    }
    
    .popup-prev {
        left: 10px;
    }
    
    .popup-next {
        right: 10px;
    }
    
    #popupImage {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .gallery-page-section {
        padding: 100px 3% 40px;
    }
    
    .gallery-header h1 {
        font-size: 2rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* Keep 2 columns */
        grid-auto-rows: 150px;
    }
    
    /* Force simpler layout on very small screens */
    .gallery-item-large,
    .gallery-item-wide {
        grid-column: span 2;
        grid-row: span 1;
    }
    
    .gallery-item-tall {
        grid-column: span 1;
        grid-row: span 1; /* All become normal on tiny screens */
    }
    
    .featured-section {
        margin-bottom: 40px;
    }
    
    .featured-item {
        flex: 0 0 120px;
        height: 120px;
    }
    
    .overlay-content h3 {
        font-size: 1rem;
    }
    
    .overlay-content p {
        font-size: 12px;
    }
}

/* Loading States */
.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
}

.loading-spinner i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.empty-state p {
    font-size: 18px;
    margin: 20px 0;
}