<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="robots" content="noindex,nofollow">
  <meta name="color-scheme" content="dark light">
  <title><%= pageTitle %> - SimuTradeX</title>
  <link rel="stylesheet" href="/assets/css/admin.css?v=20260703-nav-captcha">
  <link rel="stylesheet" href="/assets/css/auth.css?v=20260703-nav-captcha">
</head>
<body class="auth-body">
  <main class="auth-page">
    <section class="auth-panel" aria-labelledby="login-title">
      <div class="auth-brand">
        <div class="auth-logo" aria-hidden="true">ST</div>
        <div>
          <p class="auth-eyebrow">Admin Console</p>
          <h1 id="login-title" class="auth-title">SimuTradeX</h1>
        </div>
      </div>
      <p class="auth-copy">Sign in to manage users, payments, plans, and platform settings.</p>

      <% if (error) { %>
        <div class="auth-alert"><%= error %></div>
      <% } %>

      <form action="/login" method="post" class="auth-form" autocomplete="on">
        <input type="hidden" name="_csrf" value="<%= csrfToken %>">
        <% const hasCaptcha = typeof captchaToken !== 'undefined' && captchaToken; %>
        <label class="auth-field">
          <span>Email</span>
          <input class="input w-full" type="email" name="email" value="<%= email %>" required autocomplete="username" maxlength="190">
        </label>
        <label class="auth-field">
          <span>Password</span>
          <input class="input w-full" type="password" name="password" required autocomplete="current-password" maxlength="256">
        </label>
        <% if (hasCaptcha) { %>
        <label class="auth-field">
          <span>Security code</span>
          <div class="auth-captcha-row">
            <img class="auth-captcha-image" src="/login/captcha.svg?c=<%= captchaToken %>&v=<%= captchaVersion %>" width="150" height="48" alt="Numeric security code">
            <a class="btn btn-secondary auth-captcha-refresh" href="/login?refresh=1">Refresh</a>
          </div>
          <input type="hidden" name="captcha_token" value="<%= captchaToken %>">
          <input class="input w-full" type="text" name="captcha" required inputmode="numeric" pattern="[0-9]*" maxlength="6" autocomplete="off" placeholder="Enter the number">
        </label>
        <% } %>
        <button class="btn btn-primary w-full justify-center" type="submit">Sign in</button>
      </form>
    </section>
  </main>
</body>
</html>
