<?php
$bp = Auth::basePath();
?>
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Register — <?= h(cfg('app_name')) ?></title>
  <script>
    (function () {
      var t = localStorage.getItem('crash_console_theme');
      if (t === 'light' || t === 'dark') document.documentElement.setAttribute('data-theme', t);
      var l = localStorage.getItem('crash_console_lang');
      if (l === 'en' || l === 'ru') document.documentElement.setAttribute('lang', l);
    })();
  </script>
  <link rel="stylesheet" href="<?= h($bp) ?>/assets/css/app.css">
  <script src="<?= h($bp) ?>/assets/js/i18n.js" defer></script>
  <?php AnalyticsHead::render('crashes_register'); ?>
</head>
<body class="login-page" data-base-path="<?= h($bp) ?>">
  <div class="login-locale">
    <label class="toolbar-select locale-toolbar-select" data-i18n-title="lang.label" title="Language">
      <span class="locale-flag" aria-hidden="true">🇬🇧</span>
      <select class="lang-select" data-i18n-aria="lang.label" aria-label="Language">
        <option value="en">EN</option>
        <option value="ru">RU</option>
      </select>
    </label>
  </div>
  <form class="login-card" method="post" action="<?= h($bp) ?>/register">
    <h1 data-i18n="register.title">Create account</h1>
    <p class="muted" data-i18n="register.hint">We will email a verification link before you can sign in.</p>
    <?php if (!empty($registerError)): ?>
      <div class="alert"><?= h($registerError) ?></div>
    <?php endif; ?>
    <?php if (!empty($registerSuccess)): ?>
      <div class="alert alert--ok"><?= h($registerSuccess) ?></div>
    <?php endif; ?>
    <label><span data-i18n="register.email">Email</span>
      <input name="email" type="email" autocomplete="email" required value="<?= h($registerEmail ?? '') ?>"></label>
    <label><span data-i18n="register.username">Username</span>
      <input name="username" autocomplete="username" value="<?= h($registerUsername ?? '') ?>"></label>
    <label><span data-i18n="register.password">Password</span>
      <input name="password" type="password" autocomplete="new-password" minlength="10" required></label>
    <button type="submit" data-i18n="register.submit">Register</button>
    <p class="hint"><a href="<?= h($bp) ?>/login" data-i18n="register.back_login">Back to sign in</a></p>
  </form>
  <?php platform_render_footer(); ?>
</body>
</html>
