<div class="p-30">
  <h2><?= e(app_zh('登录')) ?></h2>

  <?php
    $loginUsername = (string)($login_username ?? '');
    $loginMath = is_array($login_math ?? null) ? $login_math : ['required' => false, 'question' => ''];
  ?>

  <?php if (!empty($auth_blocked)): ?>
    <p class="text-muted" style="margin-top:12px;"><?= e(app_zh('请根据上方提示联系站长处理授权后再登录。')) ?></p>
  <?php else: ?>
    <form method="post" action="<?= e_url(base_url('login')) ?>">
      <?= csrf_field() ?>
      <div class="form-group">
        <label><?= e(app_zh('账号')) ?></label>
        <input class="form-control" name="username" value="<?= e($loginUsername) ?>" required>
      </div>
      <div class="form-group">
        <label><?= e(app_zh('密码')) ?></label>
        <input type="password" class="form-control" name="password" required>
      </div>
      <?php if (!empty($loginMath['required'])): ?>
        <div class="alert alert-warning" style="margin-bottom:15px;">
          <?= e(app_zh('连续输错已触发安全验证，请先完成下方计算题。')) ?>
        </div>
        <div class="form-group">
          <label><?= e(app_zh('计算题')) ?></label>
          <div class="form-control" style="height:auto;background:#f8fafc;color:#0f172a;font-weight:600;"><?= e((string)($loginMath['question'] ?? '')) ?></div>
        </div>
        <div class="form-group">
          <label><?= e(app_zh('计算结果')) ?></label>
          <input class="form-control" name="math_answer" inputmode="numeric" autocomplete="off" required>
        </div>
      <?php endif; ?>
      <button class="btn btn-primary btn-block" type="submit"><?= e(app_zh('登录')) ?></button>
    </form>
  <?php endif; ?>

  <p class="m-t-15"><?= e(app_zh('还没有账号？')) ?> <a href="<?= e_url(base_url('register')) ?>"><?= e(app_zh('立即注册')) ?></a></p>
</div>
