<?php
session_start();

if (!isset($_SESSION['appointment_success'])) {
    header("Location: ../patient/patient_management_dashboard.php");
    exit;
}


$data = $_SESSION['appointment_success'];

$appointment_id = htmlspecialchars($data['appointment_id']);
$patient_no     = htmlspecialchars($data['patient_no']);

// Optional cleanup to avoid reuse on refresh
unset($_SESSION['appointment_success']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Appointment Created</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
body {
    margin: 0;
    background: rgba(0,0,0,0.55);
    font-family: "Segoe UI", Tahoma, sans-serif;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: #ffffff;
    width: 420px;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    text-align: center;
    animation: scaleIn .3s ease;
}

@keyframes scaleIn {
    from { transform: scale(.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #2a9d8f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 16px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #023e8a;
    margin-bottom: 6px;
}

.modal-text {
    font-size: 14px;
    color: #444;
    margin-bottom: 14px;
}

.appointment-ref {
    background: #f1f6fb;
    border-radius: 8px;
    padding: 10px;
    font-weight: 700;
    color: #023e8a;
    letter-spacing: .4px;
}

.redirect-note {
    font-size: 12px;
    color: #777;
    margin-top: 14px;
}
</style>

<script>
setTimeout(() => {
    window.location.href = "../patient/patient_management_dashboard.php";
}, 3500);
</script>
</head>

<body>
<div class="modal-overlay">
    <div class="modal-box">
        <div class="modal-icon">✓</div>
        <div class="modal-title">Appointment Booked Successfully</div>
        <div class="modal-text">
            The appointment has been duly recorded.
        </div>
        <div class="appointment-ref">
            Appointment No.: <?php echo $appointment_id; ?><br>
        </div>
        <div class="redirect-note">
            Redirecting to patient dashboard…
        </div>
    </div>
</div>
</body>
</html>
