<?php
use App\Core\{Csrf, Session};
use function App\Core\{__, e, url};

$errors = Session::flash('auth_errors') ?: [];
$old = Session::flash('old_input') ?: [];
$resetLink = Session::flash('reset_link');
?>
<section class="auth-card">
    <h1><?= e(__('forgot_password')) ?></h1>
    <p class="auth-copy"><?= e(__('forgot_intro')) ?></p>

    <?php if ($errors): ?>
        <div class="auth-errors" role="alert">
            <?php foreach ($errors as $error): ?><p><?= e($error) ?></p><?php endforeach; ?>
        </div>
    <?php endif; ?>

    <?php if ($resetLink): ?>
        <div class="auth-note">
            <strong><?= e(__('development_reset_link')) ?></strong>
            <a href="<?= e($resetLink) ?>"><?= e($resetLink) ?></a>
            <small><?= e(__('production_mail_todo')) ?></small>
        </div>
    <?php endif; ?>

    <form method="post" action="<?= url('/sifremi-unuttum') ?>" novalidate>
        <?= Csrf::field() ?>
        <label>
            <?= e(__('email')) ?>
            <input name="email" type="email" autocomplete="email" required value="<?= e($old['email'] ?? '') ?>">
        </label>
        <button class="pill primary" type="submit"><?= e(__('send_reset_link')) ?></button>
    </form>

    <div class="auth-links">
        <a href="<?= url('/giris-yap') ?>"><?= e(__('back_to_login')) ?></a>
    </div>
</section>
