{% extends 'auth/master.twig' %}
{% from 'macros.twig' import avatar %}
{% from '_layout/input.twig' import input_hidden, input_csrf, input_text %}

{% set title = 'Login' %}

{% block content %}
    <form class="container auth__container auth__login js-login-form" method="post" action="{{ url('auth-login') }}">
        {{ input_csrf() }}
        {{ input_hidden('login[redirect]', login_redirect) }}

        <div class="container__title">
            <div class="container__title__background"></div>
            <div class="auth__login__header">
                <div class="auth__login__avatar">
                    {{ avatar(0, 100, 'Avatar', {'class':'js-login-avatar'}) }}
                </div>
            </div>
        </div>

        {% if login_notices|length > 0 %}
            <div class="warning auth__warning">
                <div class="warning__content">
                    {% for notice in login_notices %}
                        <p class="auth__warning__paragraph">{{ notice }}</p>
                    {% endfor %}
                </div>
            </div>
        {% elseif login_welcome %}
            <div class="warning auth__warning auth__warning--welcome">
                <div class="warning__content">
                    <p class="auth__warning__paragraph">Welcome to Flashii, you may now log in!</p>
                </div>
            </div>
        {% endif %}

        <label class="auth__label">
            <div class="auth__label__text">
                Username
            </div>
            <div class="auth__label__value">
                {{ input_text('login[username]', 'auth__label__input js-login-username', login_username, 'text', '', true, null, 1, not login_welcome) }}
            </div>
        </label>

        <label class="auth__label">
            <div class="auth__label__text">
                Password
                {% if login_can_reset_password %}
                    <a href="{{ url('auth-forgot') }}" class="auth__label__action" tabindex="4">Forgot?</a>
                {% endif %}
            </div>
            <div class="auth__label__value">
                {{ input_text('login[password]', 'auth__label__input', '', 'password', '', true, null, 2, login_welcome) }}
            </div>
        </label>

        <div class="auth__buttons">
            <button class="input__button auth__buttons__button" tabindex="3">Log in</button>
            {% if login_can_register %}
                <a href="{{ url('auth-register') }}" class="input__button auth__buttons__button auth__buttons__button--minor" tabindex="5">Create an account</a>
            {% endif %}
        </div>
    </form>
{% endblock %}
