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

$errors = Session::flash('auth_errors') ?: [];
$old = Session::flash('old_input') ?: [];
$identity = $old['identity'] ?? ($rememberedIdentity ?? '');
?>
<section class="auth-card">
    <h1><?= e(__('login')) ?></h1>
    <p class="auth-copy"><?= e(__('login_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; ?>

    <form method="post" action="<?= url('/giris-yap') ?>" novalidate>
        <?= Csrf::field() ?>
        <label>
            <?= e(__('username_or_email')) ?>
            <input name="identity" type="text" autocomplete="username" required value="<?= e($identity) ?>">
        </label>
        <label>
            <?= e(__('password')) ?>
            <input name="password" type="password" autocomplete="current-password" required>
        </label>
        <label class="check-row">
            <input name="remember" type="checkbox" value="1" <?= $identity ? 'checked' : '' ?>>
            <span><?= e(__('remember_me')) ?></span>
        </label>
        <button class="pill primary" type="submit"><?= e(__('login')) ?></button>
    </form>

    <div class="auth-links">
        <a href="<?= url('/sifremi-unuttum') ?>"><?= e(__('forgot_password')) ?></a>
        <a href="<?= url('/kayit') ?>"><?= e(__('register')) ?></a>
    </div>
</section>
