<?php
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}

function fp_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}

$error = $_SESSION['error'] ?? '';
$success = $_SESSION['success'] ?? '';
unset($_SESSION['error'], $_SESSION['success']);
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<title>Reset Password</title>
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;700;900&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
<style>
body{font-family:Cairo,sans-serif;min-height:100vh;background:linear-gradient(135deg,#0f172a,#1d4ed8);display:flex;align-items:center;justify-content:center;padding:20px}
.cardx{max-width:520px;width:100%;background:#fff;border-radius:28px;box-shadow:0 25px 70px rgba(0,0,0,.25);overflow:hidden}
.head{background:linear-gradient(135deg,#0f172a,#2563eb);color:#fff;padding:28px}
.form-control{border-radius:16px;padding:13px}
.btn-main{border:0;border-radius:18px;padding:13px;font-weight:900;background:linear-gradient(135deg,#16a34a,#22c55e);color:#fff}
</style>
</head>
<body>
<div class="cardx">
    <div class="head">
        <h3 class="fw-bold mb-1">استعادة كلمة المرور</h3>
        <div class="opacity-75">Enter your email to receive a reset link.</div>
    </div>

    <div class="p-4">
        <?php if ($error): ?><div class="alert alert-danger"><?= fp_h($error) ?></div><?php endif; ?>
        <?php if ($success): ?><div class="alert alert-success"><?= fp_h($success) ?></div><?php endif; ?>

        <form method="post" action="/easychair/forgot-password">
            <label class="form-label fw-bold">Email</label>
            <input type="email" name="email" class="form-control mb-3" required>
            <button class="btn-main w-100">Send Reset Link</button>
        </form>

        <div class="text-center mt-3">
            <a href="/easychair/login">Back to login</a>
        </div>
    </div>
</div>
</body>
</html>
