<div class="gallery-section" x-data="{ shown: 5 }">
    <h2 class="gallery-title">{{ $individualZone->second_title }}</h2>
    <div class="gallery-grid">
        @foreach($individualZone->main_images as $i => $img)
            <div class="gallery-img-wrapper" x-show="{{ $i }} < shown">
                <img src="{{ asset('storage/' . $img) }}" alt="Gallery Image {{ $i+1 }}">
            </div>
        @endforeach
    </div>
    @if(count($individualZone->main_images) > 5)
    <div class="gallery-buttons" style="display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem;">
        <button class="gallery-view-more" x-show="shown < {{ count($individualZone->main_images) }}" @click="shown += 5">
            View More
        </button>
        <button class="gallery-view-more" x-show="shown > 5" @click="shown = 5">
            Show Less
        </button>
    </div>
    @endif
</div>

<style>
.gallery-section {
    background: #16507b;
    padding: 2.5rem 0 3rem 0;
    text-align: center;
}
.gallery-title {
    color: #fff;
    font-size: 1.5rem;
    font-family: Poppins, Arial, sans-serif;
    font-weight: 500;
    margin-bottom: 2rem;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 180px 180px;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto 2.5rem auto;
}
.gallery-img-wrapper {
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-grid > .gallery-img-wrapper:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 2; }
.gallery-grid > .gallery-img-wrapper:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
.gallery-grid > .gallery-img-wrapper:nth-child(3) { grid-column: 3 / 4; grid-row: 1 / 3; }
.gallery-grid > .gallery-img-wrapper:nth-child(4) { grid-column: 1 / 2; grid-row: 2 / 3; }
.gallery-grid > .gallery-img-wrapper:nth-child(5) { grid-column: 2 / 3; grid-row: 2 / 3; }

.gallery-view-more {
    background: #16507b;
    color: #fff;
    border: 1px solid #fff;
    border-radius: 4px;
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    font-family: Poppins, Arial, sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    margin-top: 1.5rem;
}
.gallery-view-more:hover {
    background: #fff;
    color: #16507b;
}
/* Enhanced responsive styles */
@media (max-width: 1200px) {
    .gallery-section {
        padding: 2.2rem 0 2.8rem 0;
    }
    .gallery-title {
        font-size: 1.4rem;
        margin-bottom: 1.8rem;
    }
    .gallery-grid {
        grid-template-rows: 160px 160px;
        gap: 0.9rem;
        max-width: 1000px;
        margin: 0 auto 2.2rem auto;
    }
    .gallery-view-more {
        padding: 0.45rem 1.3rem;
        font-size: 0.95rem;
        margin-top: 1.3rem;
    }
}

@media (max-width: 992px) {
    .gallery-section {
        padding: 2rem 0 2.5rem 0;
    }
    .gallery-title {
        font-size: 1.3rem;
        margin-bottom: 1.6rem;
    }
    .gallery-grid {
        grid-template-rows: 150px 150px;
        gap: 0.8rem;
        max-width: 900px;
        margin: 0 auto 2rem auto;
    }
    .gallery-view-more {
        padding: 0.4rem 1.2rem;
        font-size: 0.9rem;
        margin-top: 1.2rem;
    }
}

@media (max-width: 768px) {
    .gallery-section {
        padding: 1.8rem 0 2.2rem 0;
    }
    .gallery-title {
        font-size: 1.2rem;
        margin-bottom: 1.4rem;
    }
    .gallery-grid {
        grid-template-rows: 140px 140px;
        gap: 0.7rem;
        max-width: 800px;
        margin: 0 auto 1.8rem auto;
    }
    .gallery-view-more {
        padding: 0.35rem 1.1rem;
        font-size: 0.85rem;
        margin-top: 1.1rem;
    }
}

@media (max-width: 700px) {
    .gallery-section {
        padding: 1.5rem 0 2rem 0;
    }
    .gallery-title {
        font-size: 1.1rem;
        margin-bottom: 1.2rem;
    }
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 140px 140px 140px;
        gap: 0.6rem;
        max-width: 600px;
        margin: 0 auto 1.5rem auto;
    }
    .gallery-grid > .gallery-img-wrapper:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 2; }
    .gallery-grid > .gallery-img-wrapper:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
    .gallery-grid > .gallery-img-wrapper:nth-child(3) { grid-column: 1 / 3; grid-row: 2 / 3; }
    .gallery-grid > .gallery-img-wrapper:nth-child(4) { grid-column: 1 / 2; grid-row: 3 / 4; }
    .gallery-grid > .gallery-img-wrapper:nth-child(5) { grid-column: 2 / 3; grid-row: 3 / 4; }
    .gallery-view-more {
        padding: 0.3rem 1rem;
        font-size: 0.8rem;
        margin-top: 1rem;
    }
}

@media (max-width: 600px) {
    .gallery-section {
        padding: 1.2rem 0 1.8rem 0;
    }
    .gallery-title {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    .gallery-grid {
        grid-template-rows: 120px 120px 120px;
        gap: 0.5rem;
        max-width: 500px;
        margin: 0 auto 1.2rem auto;
    }
    .gallery-view-more {
        padding: 0.25rem 0.9rem;
        font-size: 0.75rem;
        margin-top: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gallery-section {
        padding: 1rem 0 1.5rem 0;
    }
    .gallery-title {
        font-size: 0.95rem;
        margin-bottom: 0.8rem;
    }
    .gallery-grid {
        grid-template-rows: 100px 100px 100px;
        gap: 0.4rem;
        max-width: 400px;
        margin: 0 auto 1rem auto;
    }
    .gallery-view-more {
        padding: 0.2rem 0.8rem;
        font-size: 0.7rem;
        margin-top: 0.8rem;
    }
}

@media (max-width: 400px) {
    .gallery-section {
        padding: 0.8rem 0 1.2rem 0;
    }
    .gallery-title {
        font-size: 0.9rem;
        margin-bottom: 0.6rem;
    }
    .gallery-grid {
        grid-template-rows: 90px 90px 90px;
        gap: 0.3rem;
        max-width: 350px;
        margin: 0 auto 0.8rem auto;
    }
    .gallery-view-more {
        padding: 0.15rem 0.7rem;
        font-size: 0.65rem;
        margin-top: 0.7rem;
    }
}

@media (max-width: 360px) {
    .gallery-section {
        padding: 0.6rem 0 1rem 0;
    }
    .gallery-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }
    .gallery-grid {
        grid-template-rows: 80px 80px 80px;
        gap: 0.25rem;
        max-width: 300px;
        margin: 0 auto 0.6rem auto;
    }
    .gallery-view-more {
        padding: 0.1rem 0.6rem;
        font-size: 0.6rem;
        margin-top: 0.6rem;
    }
}
.gallery-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}
</style>

<!-- Alpine.js for interactivity (add this once in your layout if not already present) -->
<script src="//unpkg.com/alpinejs" defer></script>