<?php
/**
 * Expected variables:
 * $paginationData = [
 *   'current_page' => 1,
 *   'total_pages' => 5,
 *   'total_items' => 50,
 *   'url_pattern' => '/items?page=' // usage: url_pattern . page_number
 * ]
 */
if (isset($paginationData) && $paginationData['total_pages'] > 1):
    $curr = $paginationData['current_page'];
    $total = $paginationData['total_pages'];
    $url = $paginationData['url_pattern'];
?>
<div class="d-flex justify-between align-center mt-4">
    <div class="text-sm text-muted">
        Showing page <?= $curr ?> of <?= $total ?> (Total: <?= $paginationData['total_items'] ?? '?' ?> items)
    </div>
    
    <div class="pagination">
        <a href="<?= $curr > 1 ? $url . ($curr - 1) : '#' ?>" class="page-btn <?= $curr <= 1 ? 'disabled' : '' ?>">
            <i class="fas fa-chevron-left"></i>
        </a>
        
        <?php for($i = 1; $i <= $total; $i++): ?>
            <?php 
            // Simple logic to show surrounding pages
            if ($i == 1 || $i == $total || ($i >= $curr - 2 && $i <= $curr + 2)): 
            ?>
                <a href="<?= $url . $i ?>" class="page-btn <?= $i == $curr ? 'active' : '' ?>"><?= $i ?></a>
            <?php elseif ($i == $curr - 3 || $i == $curr + 3): ?>
                <span class="page-btn disabled">...</span>
            <?php endif; ?>
        <?php endfor; ?>
        
        <a href="<?= $curr < $total ? $url . ($curr + 1) : '#' ?>" class="page-btn <?= $curr >= $total ? 'disabled' : '' ?>">
            <i class="fas fa-chevron-right"></i>
        </a>
    </div>
</div>
<?php endif; ?>
