<?php include(__DIR__ . '/../includes/header.php'); ?>
<?php include(__DIR__ . '/../includes/helpers.php'); ?>

<?php
// Load bookies data
$bookies = load_json('bookies.json');

// Calculate Payment Friendliness Score
function calculate_payment_score($payments) {
    $score = 0;
    if (!empty($payments['eft'])) $score += 15;
    if (!empty($payments['instant_eft'])) $score += 15;
    if (!empty($payments['card'])) $score += 15;
    if (!empty($payments['e_wallet'])) $score += 15;
    if (!empty($payments['crypto'])) $score += 20; // bonus weight for crypto
    if (!empty($payments['voucher'])) $score += 10;
    return min($score, 100);
}

// Explanation
function payment_explanation($score) {
    if ($score >= 80) return "Excellent: wide coverage, crypto-friendly";
    if ($score >= 60) return "Good: multiple reliable methods";
    if ($score >= 40) return "Average: limited payment options";
    return "Low: few or unreliable payment methods";
}
?>

<main>
  <!-- Intro Block -->
  <section class="payment-intro">
    <h1>Payment Methods Intelligence</h1>
    <p>Deposits and withdrawals are the backbone of betting. Our Payment Friendliness Score shows which bookmakers offer the widest and most reliable options.</p>
  </section>

  <!-- Info Cards -->
  <section class="cards">
    <div class="card">
      <h3>What is Payment Friendliness?</h3>
      <p>A composite rating based on the number and reliability of supported payment methods, including EFT, cards, e-wallets, vouchers, and crypto.</p>
    </div>
    <div class="card">
      <h3>Scoring</h3>
      <p>Each supported method adds points. Crypto adds bonus weight. Higher scores mean more flexibility and reliability.</p>
    </div>
    <div class="card">
      <h3>Why it Matters</h3>
      <p>Reliable deposits and withdrawals ensure bettors can access funds quickly and securely, with minimal friction.</p>
    </div>
  </section>

  <!-- Comparison Table Bubble -->
  <section class="comparison-table info-bubble">
    <h2>Bookmakers Ranked by Payment Friendliness</h2>
    <table>
      <thead>
        <tr>
          <th>Bookmaker</th>
          <th>EFT</th>
          <th>Instant EFT</th>
          <th>Card</th>
          <th>E-Wallet</th>
          <th>Crypto</th>
          <th>Voucher</th>
          <th>Payment Score</th>
          <th>Explanation</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($bookies as $bookie): ?>
          <?php $score = calculate_payment_score($bookie['payments']); ?>
          <tr>
            <td><?php echo $bookie['name']; ?></td>
            <td><?php echo !empty($bookie['payments']['eft']) ? '✅' : '❌'; ?></td>
            <td><?php echo !empty($bookie['payments']['instant_eft']) ? '✅' : '❌'; ?></td>
            <td><?php echo !empty($bookie['payments']['card']) ? '✅' : '❌'; ?></td>
            <td><?php echo !empty($bookie['payments']['e_wallet']) ? '✅' : '❌'; ?></td>
            <td><?php echo !empty($bookie['payments']['crypto']) ? '✅' : '❌'; ?></td>
            <td><?php echo !empty($bookie['payments']['voucher']) ? '✅' : '❌'; ?></td>
            <td><?php echo $score; ?>/100</td>
            <td><?php echo payment_explanation($score); ?></td>
          </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
  </section>

  <!-- Disclaimer Bubble -->
  <section class="info-bubble disclaimer">
    <h2>Disclaimer</h2>
    <p>PuntersRoad provides educational intelligence metrics to help South African bettors make informed decisions. We do not provide odds or betting services.</p>
  </section>
</main>

<?php include(__DIR__ . '/../includes/footer.php'); ?>

