<!DOCTYPE html>
<html lang="{{ get_admin_language() }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ t('twofa.login_title') }} - AliothPress</title>
    <link rel="stylesheet" href="{{ static_v('css/admin.css') }}">
</head>
<body class="auth-page">
    <div class="auth-card">
        <h1><img src="{{ url_for('static', filename='img/admin-star.png') }}" alt="" width="32" height="32" class="sidebar-brand-icon"> AliothPress</h1>
        <p class="auth-subtitle">{{ t('twofa.login_title') }}</p>

        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }}">{{ message }}</div>
                {% endfor %}
            {% endif %}
        {% endwith %}

        <p class="help-text">{{ t('twofa.login_intro') }}</p>

        <form method="POST" action="{{ url_for('twofa_verify') }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <div class="form-group">
                <label for="code">{{ t('twofa.login_code_label') }}</label>
                <input type="text" id="code" name="code" required autofocus
                       autocomplete="one-time-code" inputmode="text"
                       spellcheck="false">
                <div class="help-text">{{ t('twofa.login_recovery_hint') }}</div>
            </div>
            <div class="form-group">
                <label>
                    <input type="checkbox" name="trust" value="1">
                    {{ t('twofa.login_trust_label') }}
                </label>
            </div>
            <button type="submit">{{ t('twofa.login_submit') }}</button>
        </form>

        {% if email_available %}
        <form method="POST" action="{{ url_for('twofa_email_code') }}" class="mt-3">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <button type="submit" class="btn btn-secondary">
                {{ t('twofa.login_email_send') }}
            </button>
        </form>
        {% endif %}

        <div class="auth-link">
            <a href="{{ url_for('admin_login') }}">{{ t('twofa.login_back') }}</a>
        </div>
    </div>
</body>
</html>
