<?php
/**
 * Starter 2026 — Payment Methods Display (Premium)
 * Shows available payment gateway icons/badges for checkout
 * CodeIgniter 3.1.9
 */
?>

<div class="s26-payment-methods">
    <?php if(empty($payment_gateways)): ?>
        <div class="s26-payment-empty">
            <i class="fas fa-credit-card"></i>
            <p><?= __('store.no_payment_options') ?? 'No payment options available' ?></p>
        </div>
    <?php else: ?>
        <div class="s26-payment-grid">
            <?php $i = 0; foreach($payment_gateways as $key => $value): ?>
            <a class="s26-payment-card <?= ($i == 0) ? 's26-payment-card--active active' : '' ?> payment-gateway-step"
               data-value="<?= $value['name'] ?>" href="javascript:void(0);">
                <div class="s26-payment-card__icon">
                    <img src="<?= base_url($value['icon']) ?>" alt="<?= htmlspecialchars($value['title'] ?? '') ?>"
                         onerror="this.parentElement.innerHTML='<i class=\'fas fa-credit-card\'></i>'">
                </div>
                <span class="s26-payment-card__name"><?= htmlspecialchars($value['title'] ?? '') ?></span>
                <div class="s26-payment-card__check">
                    <i class="fas fa-check-circle"></i>
                </div>
            </a>
            <input type="radio" name="payment_gateway" value="<?= $value['name'] ?>" <?= ($i == 0) ? "checked" : "" ?> style="display:none;">
            <?php $i++; endforeach; ?>
        </div>
    <?php endif; ?>
</div>


<script type="text/javascript">
$(document).on('click', ".s26-payment-card", function(){
    $('.s26-payment-card').removeClass('active s26-payment-card--active');
    $(this).addClass('active s26-payment-card--active');
    $('input[name="payment_gateway"][value="'+$(this).data('value')+'"]').trigger('click');
});
</script>
