<?php

declare(strict_types=1);

require DENTAL_ROOT . '/app/bootstrap.php';
require DENTAL_ROOT . '/app/layout.php';

$receipt = $_SESSION['public_request_receipt'] ?? null;
if (!is_array($receipt)) {
    header('Location: index.php#appointment');
    exit;
}
unset($_SESSION['public_request_receipt']);
$clinic = public_clinic_profile();
render_header('Appointment Request Received', true);
render_public_nav('appointment');
?>
<main class="request-received-page">
    <section class="request-received-card">
        <div class="success-seal">✓</div>
        <span class="eyebrow">Request submitted</span>
        <h1>Thank you, <?= e((string) $receipt['name']) ?>.</h1>
        <p>Your appointment request has been sent to <?= e((string) $clinic['name']) ?> for review.</p>
        <div class="receipt-reference"><span>Reference number</span><strong><?= e((string) $receipt['reference']) ?></strong></div>
        <dl class="receipt-details">
            <dt>Service</dt><dd><?= e((string) $receipt['service']) ?></dd>
            <dt>Preferred schedule</dt><dd><?= e(date('F j, Y', strtotime((string) $receipt['preferred_date']))) ?> at <?= e(date('g:i A', strtotime((string) $receipt['preferred_time']))) ?></dd>
            <dt>Status</dt><dd>Awaiting clinic review</dd>
        </dl>
        <div class="public-notice"><strong>This is not yet a confirmed appointment.</strong> The clinic will contact you after checking dentist and chair availability. Keep the reference number for follow-up.</div>
        <div class="form-submit-row"><a class="btn primary" href="index.php">Return to Clinic Home</a><a class="btn ghost" href="appointment-returning.php">Submit Another Request</a></div>
    </section>
</main>
<?php
render_public_footer();
render_footer(true);
