<?php
require_once 'config/db.php';
require_once 'includes/auth.php';

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

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'] ?? '';
    
    // Simulação de recuperação (Em um sistema real, enviaria e-mail com token)
    $stmt = $pdo->prepare("SELECT * FROM usuarios WHERE email = ?");
    $stmt->execute([$email]);
    $user = $stmt->fetch();

    if ($user) {
        $message = "Um link de recuperação foi enviado para o seu e-mail funcional (Simulação).";
    } else {
        $error = "E-mail não encontrado em nossa base de dados.";
    }
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Recuperar Senha - MEC Center</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <script src="https://unpkg.com/lucide@latest"></script>
    <style>
        body { font-family: 'Inter', sans-serif; background-color: #f8fafc; }
    </style>
</head>
<body class="flex items-center justify-center min-h-screen">
    <div class="w-full max-w-md p-8 bg-white rounded-2xl shadow-xl border border-slate-100">
        <div class="mb-8">
            <a href="login.php" class="inline-flex items-center text-sm text-blue-600 hover:underline mb-6">
                <i data-lucide="arrow-left" class="w-4 h-4 mr-1"></i> Voltar ao Login
            </a>
            <h1 class="text-2xl font-bold text-slate-800">Recuperar Senha</h1>
            <p class="text-slate-500">Insira seu e-mail para receber instruções</p>
        </div>

        <?php if ($message): ?>
            <div class="mb-4 p-4 bg-green-50 text-green-700 border border-green-100 rounded-xl text-sm">
                <?php echo $message; ?>
            </div>
        <?php endif; ?>

        <?php if ($error): ?>
            <div class="mb-4 p-4 bg-red-50 text-red-700 border border-red-100 rounded-xl text-sm">
                <?php echo $error; ?>
            </div>
        <?php endif; ?>

        <form method="POST" class="space-y-6">
            <div>
                <label class="block text-sm font-medium text-slate-700 mb-1">E-mail</label>
                <input type="email" name="email" required 
                    class="w-full px-4 py-2.5 bg-slate-50 border border-slate-200 rounded-lg focus:ring-2 focus:ring-blue-500 transition-all outline-none"
                    placeholder="seu@email.com">
            </div>

            <button type="submit" 
                class="w-full py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-xl shadow-lg transition-all">
                Enviar Link de Recuperação
            </button>
        </form>
    </div>
    <script>lucide.createIcons();</script>
</body>
</html>
