<?php
session_start();
require_once 'config/database.php';

$message = '';
$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = trim($_POST['email'] ?? '');
    if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $error = 'Please enter a valid email address.';
    } else {
        // For simplicity, just show a message (you can add email sending later)
        $message = 'If the email exists, a reset link will be sent. (Email sending not configured yet)';
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Forgot Password - Invoicyble</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gradient-to-br from-blue-50 via-white to-indigo-50">
    <div class="min-h-screen flex items-center justify-center p-4">
        <div class="max-w-md w-full bg-white rounded-2xl shadow-xl p-8">
            <h2 class="text-3xl font-bold text-center mb-2">Reset Password</h2>
            <p class="text-gray-600 text-center mb-8">Enter your email to receive a reset link</p>
            <?php if ($message): ?>
                <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-4"><?php echo htmlspecialchars($message); ?></div>
            <?php endif; ?>
            <?php if ($error): ?>
                <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-4"><?php echo htmlspecialchars($error); ?></div>
            <?php endif; ?>
            <form method="POST" class="space-y-6">
                <div><label class="block text-gray-700 mb-2">Email Address</label><input type="email" name="email" required class="w-full px-4 py-3 rounded-lg border border-gray-300"></div>
                <button type="submit" class="w-full bg-blue-600 text-white font-semibold py-3 rounded-lg hover:bg-blue-700">Send Reset Link</button>
            </form>
            <div class="mt-6 text-center"><a href="index.php" class="text-blue-600 hover:text-blue-500">Back to Login</a></div>
        </div>
    </div>
</body>
</html>