<?php

/**
 * Custom Tailwind CSS Pagination View for CodeIgniter 4
 *
 * @var \CodeIgniter\Pager\PagerRenderer $pager
 */

$pager->setSurroundCount(2);
?>

<?php if ($pager->hasPreviousPage() || $pager->hasNextPage()): ?>
<nav aria-label="Page navigation" class="flex items-center justify-center gap-1 mt-3 mb-2 no-print">
    <?php if ($pager->hasPreviousPage()): ?>
        <a href="<?= $pager->getFirst() ?>" class="px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 text-gray-600" title="처음">&laquo;</a>
        <a href="<?= $pager->getPreviousPage() ?>" class="px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 text-gray-600" title="이전">&lsaquo;</a>
    <?php else: ?>
        <span class="px-2 py-1 text-xs border border-gray-200 rounded text-gray-300">&laquo;</span>
        <span class="px-2 py-1 text-xs border border-gray-200 rounded text-gray-300">&lsaquo;</span>
    <?php endif; ?>

    <?php foreach ($pager->links() as $link): ?>
        <?php if ($link['active']): ?>
            <span class="px-3 py-1 text-xs border border-btn-search rounded bg-btn-search text-white font-bold"><?= $link['title'] ?></span>
        <?php else: ?>
            <a href="<?= $link['uri'] ?>" class="px-3 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 text-gray-700"><?= $link['title'] ?></a>
        <?php endif; ?>
    <?php endforeach; ?>

    <?php if ($pager->hasNextPage()): ?>
        <a href="<?= $pager->getNextPage() ?>" class="px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 text-gray-600" title="다음">&rsaquo;</a>
        <a href="<?= $pager->getLast() ?>" class="px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 text-gray-600" title="마지막">&raquo;</a>
    <?php else: ?>
        <span class="px-2 py-1 text-xs border border-gray-200 rounded text-gray-300">&rsaquo;</span>
        <span class="px-2 py-1 text-xs border border-gray-200 rounded text-gray-300">&raquo;</span>
    <?php endif; ?>
</nav>
<?php endif; ?>
