<div id="product-container"> {{-- ID ini harus ada agar AJAX bisa menimpa isinya --}}
    <div class="row g-3 d-flex align-items-stretch">
        @forelse ($buket as $b)
            <div class="col-6 col-md-4 col-lg-3">
                <div class="katalogbuket-card h-100 position-relative">
                    <div class="img-wrapper mb-3">
                        <img src="{{ asset('storage/' . $b->foto) }}" class="img-fluid rounded-4"
                            alt="{{ $b->nama }}">
                    </div>
                    <h6 class="katalogbuket-product-title">{{ $b->nama }}</h6>
                    <p class="katalogbuket-product-price">Rp {{ number_format($b->harga, 0, ',', '.') }}</p>
                    <div class="spacer"></div>
                    <a href="{{ route('detail.buket', $b->id_buket . '-' . Str::slug($b->nama)) }}"
                        class="stretched-link"></a>
                </div>
            </div>
        @empty
            <div class="col-12 text-center py-5">
                <p>Buket tidak ditemukan</p>
            </div>
        @endforelse
    </div>
    @if ($buket->hasPages())
        <div class="row mt-5" id="custom-pagination">
            <div class="col-12 d-flex justify-content-between align-items-center">
                {{-- TOMBOL PREVIOUS --}}
                <div class="text-start" style="width: 160px;">
                    @if ($buket->onFirstPage())
                        <span class="btn btn-pagination btn-sm rounded-pill px-3 disabled" style="opacity: 0.5;">
                            <i class="bi bi-chevron-left me-1"></i> Sebelumnya
                        </span>
                    @else
                        <a href="{{ $buket->previousPageUrl() }}" class="btn btn-pagination">
                            <i class="bi bi-chevron-left me-1"></i> Sebelumnya
                        </a>
                    @endif
                </div>

                {{-- TOMBOL ANGKA (Looping Halaman) --}}
                <div class="d-flex justify-content-center align-items-center gap-2">
                    @foreach ($buket->getUrlRange(1, $buket->lastPage()) as $page => $url)
                        @if ($page == $buket->currentPage())
                            <span class="page-number active mt-0 rounded"
                                style="background-color: var(--bs-gray-400); color: black; font-weight: 700; padding: 5px 12px;">
                                {{ $page }}
                            </span>
                        @else
                            <a href="{{ $url }}"
                                class="page-number text-decoration-none text-muted px-3 py-1 mt-0">
                                {{ $page }}
                            </a>
                        @endif
                    @endforeach
                </div>

                {{-- TOMBOL NEXT --}}
                <div class="text-end" style="width: 160px;">
                    @if ($buket->hasMorePages())
                        <a href="{{ $buket->nextPageUrl() }}" class="btn btn-pagination btn-sm rounded-pill px-3">
                            Selanjutnya <i class="bi bi-chevron-right ms-1"></i>
                        </a>
                    @else
                        <span class="btn btn-pagination disabled btn-sm rounded-pill px-3" style="opacity: 0.5;">
                            Selanjutnya <i class="bi bi-chevron-right ms-1"></i>
                        </span>
                    @endif
                </div>
            </div>
        </div>
    @endif
</div>
