<?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';
$isConfirmed    = $booking->status === 'confirmed';
$isPending      = $booking->status === 'pending_deposit';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include APPPATH . 'Views/public/_shell_head.php'; ?>
</head>
<body>
<div class="public-shell">
    <div class="d-flex align-items-center gap-2 mb-4">
        <div class="brand-mark"><i class="bi bi-buildings-fill"></i></div>
        <div class="brand-name"><?= esc($hotelName) ?></div>
    </div>

    <?php if (session()->getFlashdata('error')): ?>
        <div class="alert alert-danger py-2 small"><?= esc(session()->getFlashdata('error')) ?></div>
    <?php endif; ?>

    <div class="public-card text-center">
        <?php if ($isConfirmed): ?>
            <i class="bi bi-check-circle-fill text-success" style="font-size: 3rem;"></i>
            <h1 class="h5 mt-3 mb-1">Booking Confirmed!</h1>
            <p class="text-muted">We look forward to hosting you, <?= esc(explode(' ', $booking->guest_name)[0]) ?>.</p>
        <?php elseif ($isPending): ?>
            <i class="bi bi-hourglass-split" style="font-size: 3rem; color: var(--brand-accent);"></i>
            <h1 class="h5 mt-3 mb-1">Payment Pending</h1>
            <p class="text-muted">Your room is held. If you already paid, this page will update shortly — if not, check your SMS for the payment link.</p>
        <?php else: ?>
            <i class="bi bi-x-circle text-danger" style="font-size: 3rem;"></i>
            <h1 class="h5 mt-3 mb-1">Booking Not Confirmed</h1>
            <p class="text-muted">This booking is currently <?= esc($booking->status) ?>. Contact the hotel if you believe this is a mistake.</p>
        <?php endif; ?>

        <div class="text-start border-top mt-3 pt-3">
            <div class="d-flex justify-content-between small mb-1"><span class="text-muted">Confirmation #</span><span class="fw-semibold">BK-<?= sprintf('%04d', $booking->id) ?></span></div>
            <div class="d-flex justify-content-between small mb-1"><span class="text-muted">Room Type</span><span class="fw-semibold"><?= esc($booking->room_type_name) ?></span></div>
            <div class="d-flex justify-content-between small mb-1"><span class="text-muted">Check In</span><span class="fw-semibold"><?= esc(date('d M Y', strtotime($booking->check_in_date))) ?></span></div>
            <div class="d-flex justify-content-between small"><span class="text-muted">Check Out</span><span class="fw-semibold"><?= esc(date('d M Y', strtotime($booking->check_out_date))) ?></span></div>
        </div>
    </div>

    <p class="text-center text-muted small mt-4 mb-0">&copy; <?= date('Y') ?> <?= esc($hotelName) ?> · Powered by MaxYields PMS</p>
</div>
</body>
</html>
