<section class="gallery-section relative overflow-hidden bg-gradient-to-b from-white via-[#FFF9F5] to-white py-24 lg:py-32" x-data="{ selectedCategory: 'All', zoomImage: null, categories: ['All', 'Painting Works', 'POP Ceiling Installation', 'Flooring & Tiling', 'Interior Décor', 'Renovations', 'Landscaping'] }">
    <div class="absolute top-20 right-10 w-[500px] h-[500px] bg-gradient-to-bl from-[#FF007A]/5 to-transparent rounded-full blur-3xl"></div>
    <div class="absolute bottom-20 left-10 w-[400px] h-[400px] bg-gradient-to-tr from-[#D87AA8]/5 to-transparent rounded-full blur-3xl"></div>

    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
        <div class="text-center max-w-3xl mx-auto mb-20">
            <span class="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-gradient-to-r from-[#FF007A] to-[#D87AA8] text-white text-xs font-bold uppercase tracking-[0.25em] mb-8 shadow-xl shadow-[#FF007A]/20">
                Project Gallery
            </span>
            <h1 class="text-4xl sm:text-5xl lg:text-6xl font-extrabold text-slate-900 tracking-tight leading-[1.08] mb-6">
                Gallery of <span class="text-transparent bg-clip-text bg-gradient-to-r from-[#FF007A] to-[#D87AA8]">completed projects</span>
            </h1>
            <p class="text-base sm:text-lg text-slate-500 leading-relaxed max-w-2xl mx-auto">Browse our recent transformations and completed spaces, organized by the service categories we deliver.</p>
        </div>

        <div class="flex flex-wrap justify-center gap-3 mb-12">
            <template x-for="category in categories" :key="category">
                <button type="button" @click="selectedCategory = category"
                    :class="selectedCategory === category ? 'text-white shadow-lg shadow-[#FF007A]/25' : 'bg-white text-premium-charcoal hover:text-white hover:shadow-md'"
                    class="rounded-full border-2 px-5 py-2.5 text-sm font-semibold transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-[#FF007A]/50"
                    style="border-color: #D87AA8;"
                    :style="selectedCategory === category ? 'background: linear-gradient(135deg, #FF007A 0%, #D87AA8 100%); border-color: transparent;' : ''">
                    <span x-text="category"></span>
                </button>
            </template>
        </div>

        <div class="grid gap-8 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
            <?php if (empty($items)): ?>
                <div class="md:col-span-3 text-center text-slate-500 py-12">No gallery items published yet. Check back soon.</div>
            <?php else: ?>
                <?php foreach ($items as $item): ?>
                <div x-show="selectedCategory==='All' || selectedCategory==='<?= htmlspecialchars($item['category'] ?? 'All') ?>'" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-y-4" x-transition:enter-end="opacity-100 translate-y-0" class="gallery-card group relative h-[400px] rounded-[2rem] overflow-hidden shadow-lg cursor-pointer" @click="zoomImage = '<?= htmlspecialchars($baseUrl) ?>/images/<?= htmlspecialchars($item['image_path']) ?>'">
                    <img src="<?= htmlspecialchars($baseUrl) ?>/images/<?= htmlspecialchars($item['image_path']) ?>" alt="<?= htmlspecialchars($item['title']) ?>" class="absolute inset-0 w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                    <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent z-10"></div>
                    <div class="absolute inset-0 bg-gradient-to-br from-[#FF007A]/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 z-10"></div>
                    <div class="relative z-20 h-full flex flex-col justify-end p-8">
                        <div class="w-12 h-12 rounded-xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white mb-4 group-hover:scale-110 group-hover:bg-gradient-to-br group-hover:from-[#FF007A] group-hover:to-[#D87AA8] transition-all duration-500">
                            <span class="material-symbols-outlined text-xl">image</span>
                        </div>
                        <h3 class="text-xl font-bold text-white mb-2"><?= htmlspecialchars($item['title']) ?></h3>
                        <p class="text-white/80 text-sm leading-relaxed"><?= htmlspecialchars($item['description'] ?? '') ?></p>
                        <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200"><?= htmlspecialchars($item['category'] ?? 'Gallery') ?></p>
                    </div>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
                    <h3 class="text-xl font-bold text-white mb-2">Kitchen Renovation</h3>
                    <p class="text-white/80 text-sm leading-relaxed">Modern kitchen design with custom finishes, lighting, and cabinetry details.</p>
                    <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200">Renovations</p>
                </div>
            </div>

            <div x-show="selectedCategory==='All' || selectedCategory==='Interior Décor'" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-y-4" x-transition:enter-end="opacity-100 translate-y-0" class="gallery-card group relative h-[400px] rounded-[2rem] overflow-hidden shadow-lg cursor-pointer" @click="zoomImage = '<?= htmlspecialchars($baseUrl) ?>/images/office.png'">
                <img src="<?= htmlspecialchars($baseUrl) ?>/images/office.png" alt="Office Space Design" class="absolute inset-0 w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent z-10"></div>
                <div class="absolute inset-0 bg-gradient-to-br from-[#FF007A]/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 z-10"></div>
                <div class="relative z-20 h-full flex flex-col justify-end p-8">
                    <div class="w-12 h-12 rounded-xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white mb-4 group-hover:scale-110 group-hover:bg-gradient-to-br group-hover:from-[#FF007A] group-hover:to-[#D87AA8] transition-all duration-500">
                        <span class="material-symbols-outlined text-xl">apartment</span>
                    </div>
                    <h3 class="text-xl font-bold text-white mb-2">Office Space Design</h3>
                    <p class="text-white/80 text-sm leading-relaxed">Professional office interiors with wall panels, lighting, and functional finishes.</p>
                    <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200">Interior Décor</p>
                </div>
            </div>

            <div x-show="selectedCategory==='All' || selectedCategory==='Flooring & Tiling'" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-y-4" x-transition:enter-end="opacity-100 translate-y-0" class="gallery-card group relative h-[400px] rounded-[2rem] overflow-hidden shadow-lg cursor-pointer" @click="zoomImage = '<?= htmlspecialchars($baseUrl) ?>/images/livingroom.png'">
                <img src="<?= htmlspecialchars($baseUrl) ?>/images/livingroom.png" alt="Luxury Living Space" class="absolute inset-0 w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent z-10"></div>
                <div class="absolute inset-0 bg-gradient-to-br from-[#FF007A]/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 z-10"></div>
                <div class="relative z-20 h-full flex flex-col justify-end p-8">
                    <div class="w-12 h-12 rounded-xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white mb-4 group-hover:scale-110 group-hover:bg-gradient-to-br group-hover:from-[#FF007A] group-hover:to-[#D87AA8] transition-all duration-500">
                        <span class="material-symbols-outlined text-xl">grid_view</span>
                    </div>
                    <h3 class="text-xl font-bold text-white mb-2">Luxury Living Space</h3>
                    <p class="text-white/80 text-sm leading-relaxed">High-end interior details with refined materials and a warm, welcoming finish.</p>
                    <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200">Flooring & Tiling</p>
                </div>
            </div>

            <div x-show="selectedCategory==='All' || selectedCategory==='POP Ceiling Installation'" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-y-4" x-transition:enter-end="opacity-100 translate-y-0" class="gallery-card group relative h-[400px] rounded-[2rem] overflow-hidden shadow-lg cursor-pointer" @click="zoomImage = '<?= htmlspecialchars($baseUrl) ?>/images/slider01.png'">
                <img src="<?= htmlspecialchars($baseUrl) ?>/images/slider01.png" alt="Contemporary Finish" class="absolute inset-0 w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent z-10"></div>
                <div class="absolute inset-0 bg-gradient-to-br from-[#FF007A]/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 z-10"></div>
                <div class="relative z-20 h-full flex flex-col justify-end p-8">
                    <div class="w-12 h-12 rounded-xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white mb-4 group-hover:scale-110 group-hover:bg-gradient-to-br group-hover:from-[#FF007A] group-hover:to-[#D87AA8] transition-all duration-500">
                        <span class="material-symbols-outlined text-xl">view_compact</span>
                    </div>
                    <h3 class="text-xl font-bold text-white mb-2">Contemporary Finish</h3>
                    <p class="text-white/80 text-sm leading-relaxed">Beautiful project finishes that create a polished and luxurious environment.</p>
                    <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200">POP Ceiling Installation</p>
                </div>
            </div>

            <div x-show="selectedCategory==='All' || selectedCategory==='Landscaping'" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-y-4" x-transition:enter-end="opacity-100 translate-y-0" class="gallery-card group relative h-[400px] rounded-[2rem] overflow-hidden shadow-lg cursor-pointer" @click="zoomImage = '<?= htmlspecialchars($baseUrl) ?>/images/slider02.png'">
                <img src="<?= htmlspecialchars($baseUrl) ?>/images/slider02.png" alt="Design-Forward Interiors" class="absolute inset-0 w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent z-10"></div>
                <div class="absolute inset-0 bg-gradient-to-br from-[#FF007A]/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 z-10"></div>
                <div class="relative z-20 h-full flex flex-col justify-end p-8">
                    <div class="w-12 h-12 rounded-xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white mb-4 group-hover:scale-110 group-hover:bg-gradient-to-br group-hover:from-[#FF007A] group-hover:to-[#D87AA8] transition-all duration-500">
                        <span class="material-symbols-outlined text-xl">park</span>
                    </div>
                    <h3 class="text-xl font-bold text-white mb-2">Design-Forward Interiors</h3>
                    <p class="text-white/80 text-sm leading-relaxed">Refined interior work with modern textures, colors, and architectural finishes.</p>
                    <p class="mt-2 text-xs uppercase tracking-[0.2em] font-semibold text-amber-200">Landscaping</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Zoom Modal -->
    <div x-show="zoomImage" @click="zoomImage = null" @keydown.escape.window="zoomImage = null" x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-200" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" class="fixed inset-0 z-50 flex items-center justify-center bg-black/85 backdrop-blur-sm p-4">
        <div class="relative max-w-5xl max-h-[90vh] w-full" @click.stop>
            <button type="button" @click="zoomImage = null" class="absolute -top-12 right-0 inline-flex items-center justify-center w-12 h-12 rounded-full bg-white/10 hover:bg-white/25 text-white transition focus:outline-none">
                <span class="material-symbols-outlined text-2xl">close</span>
            </button>
            <div class="bg-white/5 backdrop-blur-md rounded-3xl p-2 border border-white/10">
                <img :src="zoomImage" :alt="zoomImage" class="w-full h-full object-contain rounded-2xl max-h-[80vh]">
            </div>
        </div>
    </div>
</section>
