<?php
require_once __DIR__ . '/core/session.php';

// If user already started onboarding, skip
if (isset($_SESSION['onboarding']['step']) &&
    $_SESSION['onboarding']['step'] !== 'name') {
  header("Location: phone.php");
  exit;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Flowpesa — Welcome</title>
  <link rel="stylesheet" href="assets/css/style.css">
</head>
<body class="onboarding">

  <div class="card">
    <h1>Let’s get to know you</h1>
    <p class="subtitle">
      This helps personalize your Flowpesa experience.
    </p>

    <form method="POST" action="api/save_name.php">

      <div class="input-group">
        <label>First Name</label>
        <input type="text" name="first_name" required>
      </div>

      <div class="input-group">
        <label>Last Name</label>
        <input type="text" name="last_name" required>
      </div>

      <div class="input-group">
        <label>Nickname <span>(optional)</span></label>
        <input type="text" name="nickname">
      </div>

      <button type="submit" class="btn-primary">
        Continue
      </button>

    </form>
  </div>

</body>
</html>
