<?php
session_start(); require_once __DIR__.'/db.php';
if (empty($_SESSION['csrf_token'])) $_SESSION['csrf_token']=bin2hex(random_bytes(16));
$CSRF=$_SESSION['csrf_token']; $t=$_GET['type']??''; $m=$_GET['msg']??'';
?><!doctype html><html lang="ms"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Lupa Kata Laluan - DIS</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>body{font-family:Arial;background:#f6f7fb;margin:0;padding:20px}
.card{max-width:520px;margin:30px auto;background:#fff;border-radius:12px;box-shadow:0 6px 20px rgba(0,0,0,.06);padding:24px}
label{display:block;margin:10px 0 6px;font-weight:700}input,button{width:100%;padding:10px;border:1px solid #ddd;border-radius:8px}
button{margin-top:14px;background:#2563eb;color:#fff;font-weight:700;cursor:pointer}</style></head><body>
<div class="card">
  <h2>Lupa Kata Laluan</h2>
  <p>Sahkan identiti anda. Permintaan akan dihantar kepada Admin untuk tindakan reset.</p>
  <form method="post" action="forgot-password-process.php" autocomplete="off">
    <input type="hidden" name="csrf_token" value="<?=htmlspecialchars($CSRF)?>">
    <label>Nombor Staf *</label><input name="staff_number" required>
    <label>Emel (yang didaftar) *</label><input type="email" name="email" required>
    <label>4 Digit Terakhir No. IC *</label><input name="ic_last4" maxlength="4" pattern="\d{4}" required>
    <label>No. Telefon (opsyenal)</label><input name="phone">
    <button type="submit">Hantar Permintaan</button>
  </form>
  <p style="margin-top:12px"><a href="index.php">Kembali ke Login</a></p>
</div>
<?php if($t&&$m):?><script>Swal.fire({icon:'<?= $t==='success'?'success':'error'?>',title:<?= json_encode($m)?>,timer:2800,showConfirmButton:false})</script><?php endif;?>
</body></html>
