* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

/* Top Spacer */
.top-spacer {
    width: 100%;
    height: 150px;
    background: #5B9BD5;
}

/* Gallery Container */
.gallery-container {
    padding: 40px 20px;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

/* Gallery Grid - Masonry Style */
.gallery-grid {
    column-count: 5;
    column-gap: 16px;
    padding: 0;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 16px;
    break-inside: avoid;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
    width: 100%;
}

.gallery-item:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

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

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

/* ===== LIGHTBOX ===== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    overflow: hidden;
}

.lightbox.active {
    display: block;
}

/* ✅ FIXED: Position relative uchun kerak */
.lightbox-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    transform-origin: 0 0;
    cursor: zoom-in;

    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}

/* ===== BUTTONS CONTAINER ===== */
/* Close Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.8;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.lightbox-close:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.5);
}

.lightbox-close:active {
    transform: scale(0.95);
}

/* Navigation Buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 36px;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-prev {
    left: 30px;
}

.lightbox-prev:hover {
    left: 35px;
}

.lightbox-next {
    right: 30px;
}

.lightbox-next:hover {
    right: 35px;
}

/* Counter */
.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 400;
    z-index: 1001;
}

/* Error Message */
#errorMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    background: rgba(255, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    z-index: 1002;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .gallery-grid {
        column-count: 4;
    }
}

@media (max-width: 1024px) {
    .gallery-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .top-spacer {
        height: 80px;
    }

    .gallery-container {
        padding: 30px 15px;
    }

    .gallery-grid {
        column-count: 2;
        column-gap: 12px;
    }

    .gallery-item {
        margin-bottom: 12px;
    }

    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 32px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .lightbox-prev {
        left: 15px;
    }

    .lightbox-prev:hover {
        left: 18px;
    }

    .lightbox-next {
        right: 15px;
    }

    .lightbox-next:hover {
        right: 18px;
    }

    .lightbox-image {
        max-width: 95%;
        max-height: 85vh;
    }

    .lightbox-counter {
        font-size: 14px;
        padding: 6px 16px;
        bottom: 20px;
    }

    #errorMessage {
        font-size: 12px;
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        column-count: 1;
        column-gap: 0;
    }

    .gallery-container {
        padding: 20px 10px;
    }

    .gallery-item {
        margin-bottom: 10px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }

    .lightbox-nav {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-prev:hover {
        left: 12px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-next:hover {
        right: 12px;
    }
}