@if ($paginator->hasPages())
    <div class="mt-2 d-sm-flex align-items-center">
        <div>
            Showing {{ $paginator->firstItem() }} to {{ $paginator->lastItem() }} of total {{ $paginator->total() }}
        </div>
        <div class="ms-auto">
            <nav aria-label="Page navigation" class="pagination-style-1">
                <ul class="pagination mb-0 flex-wrap">
                    
                    {{-- Previous Page Link --}}
                    <li class="page-item {{ $paginator->onFirstPage() ? 'disabled' : '' }}">
                        <a class="page-link" href="{{ $paginator->previousPageUrl() }}" tabindex="-1">‹</a>
                    </li>

                    {{-- Pagination Items (Limit to 10 Pages) --}}
                    @php
                        $currentPage = $paginator->currentPage();
                        $lastPage = $paginator->lastPage();
                        $start = max(1, $currentPage - 5);
                        $end = min($lastPage, $currentPage + 4);
                    @endphp

                    {{-- First Page Link (if not in range) --}}
                    @if ($start > 1)
                        <li class="page-item">
                            <a class="page-link" href="{{ $paginator->url(1) }}">1</a>
                        </li>
                        @if ($start > 2)
                            <li class="page-item disabled"><span class="page-link">...</span></li>
                        @endif
                    @endif

                    {{-- Main Pagination Links --}}
                    @for ($page = $start; $page <= $end; $page++)
                        <li class="page-item {{ $page == $currentPage ? 'active' : '' }}">
                            <a class="page-link" href="{{ $paginator->url($page) }}">{{ $page }}</a>
                        </li>
                    @endfor

                    {{-- Last Page Link (if not in range) --}}
                    @if ($end < $lastPage)
                        @if ($end < $lastPage - 1)
                            <li class="page-item disabled"><span class="page-link">...</span></li>
                        @endif
                        <li class="page-item">
                            <a class="page-link" href="{{ $paginator->url($lastPage) }}">{{ $lastPage }}</a>
                        </li>
                    @endif

                    {{-- Next Page Link --}}
                    <li class="page-item {{ $paginator->hasMorePages() ? '' : 'disabled' }}">
                        <a class="page-link" href="{{ $paginator->nextPageUrl() }}">›</a>
                    </li>

                </ul>
            </nav>
        </div>
    </div>
@endif
