<?php
// Test what's happening with pagination logic

// Simulate the request
$_GET['page'] = '2';

// This is what shop.php does
if (is_array($_GET['page'] ?? null)) {
    $_GET['page'] = is_array($_GET['page']) ? reset($_GET['page']) : null;
}
$page = isset($_GET['page']) ? max(1, (int)($_GET['page'] ?? 1)) : 1;

echo "=== PAGINATION DEBUG ===\n";
echo "URL: ?page=2\n";
echo "GET['page'] = " . var_export($_GET['page'], true) . "\n";
echo "\$page variable = " . var_export($page, true) . "\n";
echo "Type of \$page: " . gettype($page) . "\n";
echo "intval(\$page) = " . intval($page) . "\n";
echo "\n=== CONDITION TEST ===\n";

$pageNum = intval($page);
$totalPages = 2;
$totalPageNum = intval($totalPages);

echo "\$pageNum = " . $pageNum . "\n";
echo "\$totalPageNum = " . $totalPageNum . "\n";
echo "\n";

if ($pageNum > 1) {
    echo "✓ Condition TRUE: \$pageNum > 1\n";
    echo "Previous button SHOULD BE ENABLED (orange link)\n";
} else {
    echo "✗ Condition FALSE: \$pageNum > 1\n";
    echo "Previous button SHOULD BE DISABLED (grey span)\n";
}

echo "\n";
if ($pageNum < $totalPageNum) {
    echo "✓ Condition TRUE: \$pageNum < \$totalPageNum\n";
    echo "Next button SHOULD BE ENABLED (orange link)\n";
} else {
    echo "✗ Condition FALSE: \$pageNum < \$totalPageNum\n";
    echo "Next button SHOULD BE DISABLED (grey span)\n";
}
?>
