<?php
session_start();
if (!isset($_SESSION['form_data'])) {
  header("Location: index.php");
  exit();
}
$form = $_SESSION['form_data'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Review Your Application</title>
  <link rel="stylesheet" href="assets/style.css">
</head>
<body>
  <div class="container">
    <header>
      <img src="assets/logo.png" alt="Tartu College Logo" class="logo">
      <h1>Review Your Summer Application</h1>
    </header>

    <h2>Personal Information</h2>
    <p><strong>Name:</strong> <?= htmlspecialchars($form['first_name']) ?> <?= htmlspecialchars($form['last_name']) ?></p>
    <p><strong>Preferred Name:</strong> <?= htmlspecialchars($form['preferred_name']) ?></p>
    <p><strong>Birthdate:</strong> <?= htmlspecialchars($form['birthdate']) ?></p>
    <p><strong>Gender:</strong> <?= htmlspecialchars($form['gender']) ?></p>
    <p><strong>Citizenship:</strong> <?= htmlspecialchars($form['citizenship']) ?></p>
    <p><strong>Student Status:</strong> <?= htmlspecialchars($form['student_status']) ?></p>

    <h2>Contact Information</h2>
    <p><strong>Phone:</strong> <?= htmlspecialchars($form['phone']) ?></p>
    <p><strong>Email:</strong> <?= htmlspecialchars($form['email']) ?></p>

    <h2>Home Address</h2>
    <p><?= htmlspecialchars($form['address']) ?>, <?= htmlspecialchars($form['city']) ?>, <?= htmlspecialchars($form['region']) ?>, <?= htmlspecialchars($form['country']) ?> <?= htmlspecialchars($form['postal']) ?></p>

    <h2>Emergency Contact</h2>
    <p><strong>Name:</strong> <?= htmlspecialchars($form['emergency_name']) ?></p>
    <p><strong>Phone:</strong> <?= htmlspecialchars($form['emergency_phone']) ?></p>
    <p><strong>Email:</strong> <?= htmlspecialchars($form['emergency_email']) ?></p>

    <h2>Room Details</h2>
    <p><strong>Room Type:</strong> <?= htmlspecialchars($form['room_type']) ?></p>
    <p><strong>Room Option:</strong> <?= htmlspecialchars($form['room_option']) ?></p>
    <p><strong>Suite Sharing:</strong> <?= htmlspecialchars($form['suite_share']) ?></p>
    <p><strong>Gender Neutral Friendly:</strong> <?= isset($form['gender_neutral']) ? 'Yes' : 'No' ?></p>

    <h2>Occupancy Dates</h2>
    <p><strong>Move-in:</strong> <?= htmlspecialchars($form['move_in']) ?></p>
    <p><strong>Move-out:</strong> <?= htmlspecialchars($form['move_out']) ?></p>

    <h2>Additional Info</h2>
    <p><strong>Comments:</strong> <?= nl2br(htmlspecialchars($form['comments'])) ?></p>
    <p><strong>Referral Source:</strong> <?= htmlspecialchars($form['referral']) ?></p>

    <form action="submit.php" method="post">
      <label>
        <input type="checkbox" name="agree_contract" required>
        <strong>I confirm that this application together with my payment receipt will constitute my occupancy contract with Tartu College.</strong>
        <span class="required">*</span>
      </label>

      <div class="form-actions">
        <a href="index.php" class="back-button">Back to Edit</a>
        <button type="submit">Submit Application</button>
      </div>
    </form>
  </div>
</body>
</html>
