{% extends "base.html" %}

{% block title %}Weryfikacja 2FA - Norda Biznes Partner{% endblock %}

{% block container_class %}container-narrow{% endblock %}

{% block extra_css %}
<style>
    .auth-container {
        max-width: 480px;
        margin: 0 auto;
        padding: var(--spacing-2xl) 0;
    }

    .auth-card {
        background-color: var(--surface);
        padding: var(--spacing-2xl);
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow-lg);
    }

    .auth-header {
        text-align: center;
        margin-bottom: var(--spacing-xl);
    }

    .auth-header .icon {
        font-size: 3rem;
        margin-bottom: var(--spacing-md);
    }

    .auth-header h1 {
        font-size: var(--font-size-2xl);
        color: var(--text-primary);
        margin-bottom: var(--spacing-sm);
    }

    .auth-header p {
        color: var(--text-secondary);
    }

    .form-group {
        margin-bottom: var(--spacing-lg);
    }

    .form-label {
        display: block;
        font-weight: 500;
        margin-bottom: var(--spacing-sm);
        color: var(--text-primary);
    }

    .form-input {
        width: 100%;
        padding: var(--spacing-md);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        font-size: var(--font-size-xl);
        font-family: var(--font-family);
        text-align: center;
        letter-spacing: 0.5em;
        transition: var(--transition);
    }

    .form-input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .btn-primary {
        width: 100%;
        padding: var(--spacing-md) var(--spacing-xl);
        background-color: var(--primary);
        color: white;
        border: none;
        border-radius: var(--radius);
        font-size: var(--font-size-base);
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition);
    }

    .btn-primary:hover {
        background-color: var(--primary-dark, #1d4ed8);
    }

    .backup-link {
        text-align: center;
        margin-top: var(--spacing-lg);
        padding-top: var(--spacing-lg);
        border-top: 1px solid var(--border);
    }

    .backup-link a {
        color: var(--text-secondary);
        text-decoration: none;
        font-size: var(--font-size-sm);
    }

    .backup-link a:hover {
        color: var(--primary);
    }

    .cancel-link {
        text-align: center;
        margin-top: var(--spacing-md);
    }

    .cancel-link a {
        color: var(--text-secondary);
        text-decoration: none;
        font-size: var(--font-size-sm);
    }
</style>
{% endblock %}

{% block content %}
<div class="auth-container">
    <div class="auth-card">
        <div class="auth-header">
            <div class="icon">🔐</div>
            <h1>Weryfikacja dwuetapowa</h1>
            <p>Wprowadź 6-cyfrowy kod z aplikacji uwierzytelniającej</p>
        </div>

        <form method="POST" action="{{ url_for('verify_2fa') }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

            <div class="form-group">
                <label class="form-label" for="code">Kod weryfikacyjny</label>
                <input type="text" id="code" name="code" class="form-input"
                       maxlength="6" pattern="[0-9]{6}" inputmode="numeric"
                       placeholder="000000" autocomplete="one-time-code" autofocus required>
            </div>

            <button type="submit" class="btn-primary">
                Zweryfikuj
            </button>
        </form>

        <div class="backup-link">
            <a href="#" onclick="document.getElementById('backup-form').style.display='block'; this.parentElement.style.display='none'; return false;">
                Użyj kodu zapasowego
            </a>
        </div>

        <form id="backup-form" method="POST" action="{{ url_for('verify_2fa') }}" style="display:none; margin-top: var(--spacing-lg);">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <input type="hidden" name="use_backup" value="1">

            <div class="form-group">
                <label class="form-label" for="backup-code">Kod zapasowy</label>
                <input type="text" id="backup-code" name="code" class="form-input"
                       maxlength="8" placeholder="XXXXXXXX" style="letter-spacing: 0.2em;">
            </div>

            <button type="submit" class="btn-primary">
                Użyj kodu zapasowego
            </button>
        </form>

        <div class="cancel-link">
            <a href="{{ url_for('login') }}">Anuluj i wróć do logowania</a>
        </div>
    </div>
</div>
{% endblock %}
