<?php
require_once __DIR__.'/../config/config.php';
require_once __DIR__.'/../config/database.php';
require_once __DIR__.'/../includes/functions.php';
require_once __DIR__.'/../includes/admin_functions.php';
require_once __DIR__.'/../includes/admin_auth_view.php';
$error='';$success=false;
if($_SERVER['REQUEST_METHOD']==='POST'){
 try{if(!validarCsrfToken($_POST[CSRF_TOKEN_NAME]??''))throw new RuntimeException('Sessão expirada.');afAdminRequestPasswordReset($pdo,(string)($_POST['email']??''));$success=true;}
 catch(Throwable $e){$error=$e->getMessage();}
}
afAdminAuthStart('Recuperar acesso','Enviaremos um link para o e-mail da conta administrativa.');
if($error!=='')echo '<div class="admin-auth-alert">'.esc($error).'</div>';
if($success)echo '<div class="admin-auth-alert admin-auth-success">Se o e-mail estiver cadastrado, o link de recuperação será enviado e ficará válido por 60 minutos.</div>';
?>
<form method="post" class="admin-auth-form"><?=camposCsrf()?><label>E-mail administrativo<input type="email" name="email" required></label><button class="admin-auth-button">ENVIAR LINK</button></form>
<div class="admin-auth-links"><a href="<?=SITE_URL?>/admin/login.php">← Voltar ao login</a></div>
<?php afAdminAuthEnd();
