<?php
// forgot.php
require __DIR__ . '/../Login/config.php';
if (session_status() === PHP_SESSION_NONE) session_start();

// pesan status (netral)
$status_msg = '';
if (isset($_GET['sent'])) {
    $status_msg = "Jika email terdaftar, kami telah mengirim instruksi untuk mereset password. Cek inbox atau folder Spam.";
} elseif (isset($_GET['error'])) {
    $status_msg = "Terjadi kesalahan: " . htmlspecialchars($_GET['error']);
}
?>

<!DOCTYPE html>

<html lang="id">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>Lupa Password - Pustakaia</title>
  <style>
    :root{--accent:#069797;}
    *{box-sizing:border-box;margin:0;padding:0}
    body{font-family:"Poppins",Arial,sans-serif;background:linear-gradient(135deg,#f9f9f9,#e9f5ec);color:#222;min-height:100vh;display:flex;flex-direction:column}
    header{display:flex;justify-content:space-between;align-items:center;padding:15px 30px;background:#fff;border-bottom:1px solid #ddd;position:sticky;top:0;z-index:100;width:100%}
    .logo{font-size:20px;font-weight:bold;color:var(--accent);display:flex;align-items:center;gap:10px}
    main{flex:1;display:flex;align-items:center;justify-content:center;padding:36px 20px}
    .card{width:100%;max-width:540px;background:#fff;padding:22px;border-radius:10px;box-shadow:0 6px 18px rgba(0,0,0,0.06)}
    h2{color:var(--accent);margin-bottom:10px}
    p.lead{color:#666;margin-bottom:16px}
    .input-group{margin-bottom:12px}
    label{display:block;margin-bottom:6px;color:#333;font-size:14px}
    input[type="email"]{width:100%;padding:10px;border:1px solid #ddd;border-radius:6px;font-size:14px}
    .btn{display:inline-block;padding:10px 14px;border-radius:8px;border:0;cursor:pointer;font-weight:600}
    .btn-primary{background:var(--accent);color:#fff}
    .btn-link{background:#fff;border:1px solid var(--accent);color:var(--accent)}
    .msg{padding:10px;border-radius:8px;margin-bottom:12px}
    .msg.info{background:#e8f7f6;color:var(--accent);border:1px solid #bfeae8}
    .msg.error{background:#ffecec;color:#b00000;border:1px solid #f5c2c2}
    .note{font-size:13px;color:#666;margin-top:8px}
    footer{background:#fff;padding:20px 40px;font-size:14px;color:#222;border-top:1px solid #ddd}
    .footer-bottom{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;font-size:13px}
    @media(max-width:600px){main{padding:20px}header,footer{padding:12px}}
  </style>
</head>
<body>
  <header>
    <div class="logo">
      <a href="../user/akun.php" style="text-decoration:none;color:var(--accent);font-size:18px;margin-right:8px">⬅</a>
      📚 Pustakaia
    </div>
  </header>

  <main>
    <div class="card" role="main">
      <h2>Lupa Password</h2>
      <p class="lead">Masukkan email yang terdaftar. Jika akun ada, kami akan mengirimkan link atau kode untuk mereset password.</p>

```
  <?php if ($status_msg): ?>
    <div class="msg info"><?= htmlspecialchars($status_msg) ?></div>
  <?php endif; ?>

  <form method="post" action="forgot_submit.php" novalidate>
    <div class="input-group">
      <label for="email">Email</label>
      <input id="email" name="email" type="email" required placeholder="email@domain.com">
    </div>

    <div style="display:flex;gap:8px;flex-wrap:wrap;">
      <button type="submit" class="btn btn-primary">Kirim Link Reset</button>
      <a href="../login/login.php" class="btn btn-link" style="text-align:center;line-height:30px;padding:10px 12px">Kembali ke Login</a>
    </div>
  </form>

  <div class="note">Catatan: demi keamanan, pesan di layar akan sengaja dibuat netral (tidak mengatakan apakah email terdaftar atau tidak).</div>
</div>
```

  </main>

  <footer>
    <div class="footer-bottom">
      <p>© <?= date('Y') ?>, Pustakaia | Website developed by Grup 3</p>
      <div class="footer-links">
        <a href="#">Terms of Use</a>
        <a href="#">Privacy Policy</a>
      </div>
    </div>
  </footer>
</body>
</html>
