<?php
declare(strict_types=1);

/**
 * @var \App\View\AppView $this
 * @var \App\Model\Entity\Booking $booking
 * @var bool $isDemo
 */
$slot = $booking->slot ?? null;
$teacher = $booking->teacher ?? null;
$paid = $booking->status === 'paid';
?>
<?php $this->assign('title', 'Booking confirmed · CandleCraft Academy'); ?>

<section class="cc-contact-band">
    <div class="cc-container" style="max-width: 640px;">
        <div class="cc-card cc-reveal" style="text-align: center; padding: 56px 32px;">
            <div style="width: 64px; height: 64px; border-radius: 999px; background: <?= $paid ? 'var(--cc-moss-tint)' : 'var(--cc-amber-tint)' ?>; color: <?= $paid ? 'var(--cc-moss)' : 'var(--cc-amber)' ?>; display: inline-flex; align-items: center; justify-content: center; margin: 0 auto 20px;" aria-hidden="true">
                <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>
            </div>
            <div class="cc-eyebrow" style="justify-content: center; margin-bottom: 16px;"><?= $paid ? 'Booking confirmed' : 'Booking received' ?></div>
            <h1 style="font-size: clamp(28px, 4vw, 36px); font-weight: 800; letter-spacing: -0.025em; margin-bottom: 12px;">
                <?= $paid ? "You're booked in." : 'We have your booking.' ?>
            </h1>
            <?php if ($isDemo): ?>
                <p class="cc-muted" style="margin-bottom: 16px;">⚠️ Demo mode — Stripe was not configured, so this booking was confirmed without a real payment.</p>
            <?php endif; ?>
            <p class="cc-muted" style="margin-bottom: 24px;">A confirmation email is on its way with all the details.</p>

            <div style="text-align: left; padding: 20px; background: var(--cc-bg-soft); border-radius: 12px; margin-bottom: 24px;">
                <?php if ($teacher): ?>
                    <div style="display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;"><span class="cc-muted">Teacher</span><strong><?= h($teacher->full_name) ?></strong></div>
                <?php endif; ?>
                <?php if ($slot && $slot->starts_at): ?>
                    <div style="display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;"><span class="cc-muted">When</span><strong><?= h($slot->starts_at->format('l, j M · g:i A')) ?></strong></div>
                <?php endif; ?>
                <div style="display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;"><span class="cc-muted">Class type</span><strong><?= h(ucfirst($slot->class_type ?? '—')) ?></strong></div>
                <div style="display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;"><span class="cc-muted">Booking ref</span><strong>CC-<?= sprintf('%06d', (int)$booking->id) ?></strong></div>
                <div style="display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;"><span class="cc-muted">Status</span><strong><span class="cc-badge cc-badge--<?= h($booking->status) ?>"><?= h(ucfirst($booking->status)) ?></span></strong></div>
            </div>

            <div style="display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;">
                <a class="cc-btn cc-btn--primary" href="<?= $this->Url->build(['_name' => 'home']) ?>">Back to home</a>
                <a class="cc-btn cc-btn--outline" href="<?= $this->Url->build(['_name' => 'booking_index']) ?>">Book another</a>
            </div>
        </div>
    </div>
</section>
