{% extends "base.html" %}
{% import "macros/ui.html" as ui %}

{% block title %}{{ t(key="login-totp-title", lang=lang | default(value='sk')) }}{% endblock title %}

{% block content %}
<div class="mx-auto mt-8 max-w-sm">
  <div
    class="rounded-radius border border-outline bg-surface-alt shadow-sm dark:border-outline-dark dark:bg-surface-dark-alt">
    <div
      class="flex items-center justify-between border-b border-outline px-5 py-3 dark:border-outline-dark">
      <span class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">
        {{ t(key="brand", lang=lang | default(value='sk')) }}
      </span>
      {{ ui::badge(label=t(key="auth", lang=lang | default(value='sk')), variant="primary") }}
    </div>

    <div class="p-5">
      <h1 class="text-xl font-bold text-on-surface-strong dark:text-on-surface-dark-strong">
        {{ t(key="login-totp-title", lang=lang | default(value='sk')) }}
      </h1>
      <p class="mt-2 text-sm text-on-surface dark:text-on-surface-dark">
        {{ t(key="login-totp-intro", lang=lang | default(value='sk')) }}
      </p>

      {% if error %}
      {{ ui::alert_danger(message=t(key="login-totp-error", lang=lang | default(value='sk')), extra="mt-3") }}
      {% endif %}

      <form method="post" action="/login/totp" hx-boost="false" class="mt-4 flex flex-col gap-4">
  {{ ui::csrf_field() }}
        <div class="flex flex-col gap-1">
          <label for="code"
            class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">
            {{ t(key="login-totp-code", lang=lang | default(value='sk')) }}
          </label>
          {{ ui::input(name="code", id="code", type="text", required=true, autocomplete="one-time-code", attrs='inputmode="numeric" autofocus') }}
        </div>
        {{ ui::button(label=t(key="login-totp-submit", lang=lang | default(value='sk')), type="submit", extra="mt-1 w-full") }}
      </form>

      <p class="mt-4 text-xs text-on-surface dark:text-on-surface-dark">
        {{ t(key="login-totp-backup-hint", lang=lang | default(value='sk')) }}
      </p>
    </div>
  </div>
</div>
{% endblock content %}
