<?php
$tenant = service('tenantContext')->hasTenant() ? service('tenantContext')->getTenant() : null;
$primaryColor   = safe_hex_color($tenant->primary_color ?? null, '#4f46e5');
$secondaryColor = safe_hex_color($tenant->secondary_color ?? null, '#f59e0b');
$hotelName      = $tenant->hotel_name ?? 'MaxYields PMS';
$pageTitle      = 'Redirecting to Payment';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include APPPATH . 'Views/public/_shell_head.php'; ?>
</head>
<body>
<div class="public-shell">
    <div class="public-card text-center py-5">
        <div class="spinner-border mb-3" style="color: var(--brand);" role="status"></div>
        <h1 class="h6 mb-2">Taking you to a secure payment page&hellip;</h1>
        <p class="text-muted small mb-3">Your booking is held. Complete payment to confirm it.</p>
        <a href="<?= esc($checkoutUrl) ?>" target="_top" class="btn btn-brand" id="payLink">Continue to Payment</a>
    </div>
</div>
<script>
// Break out of the iframe entirely — Hubtel's hosted checkout is a full
// third-party page not built to render in a small embedded frame, and a
// guest shouldn't enter card/MoMo details in one. target="_top" navigates
// the whole top-level tab, same as the manual link above (which stays as
// a fallback if a browser blocks the automatic redirect).
window.top.location.href = <?= json_encode($checkoutUrl) ?>;
</script>
</body>
</html>
