{% extends "admin/base_site.html" %}
{% load i18n static %}

{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} |
  {{ site_title|default:_('Account site') }}{% endblock %}

{% block branding %}
  <h1 id="site-name"><a href="{% url 'accounts:login' %}">{{ site_header|default:_('Account site') }}</a></h1>
  {% if user.is_anonymous %}
    {% include "admin/color_theme_toggle.html" %}
  {% endif %}
{% endblock %}

{% block extrastyle %}{{ block.super }}
  <link rel="stylesheet" href="{% static "admin/css/login.css" %}">
  {{ form.media }}
{% endblock %}

{% block bodyclass %}{{ block.super }} login{% endblock %}

{% block usertools %}{% endblock %}

{% block nav-global %}{% endblock %}

{% block nav-sidebar %}{% endblock %}

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block content %}
  {% if form.errors and not form.non_field_errors %}
    <p class="errornote">
      {% blocktranslate count counter=form.errors.items|length %}Please correct the error below.{% plural %}Please
        correct the errors below.{% endblocktranslate %}
    </p>
  {% endif %}

  {% if form.non_field_errors %}
    {% for error in form.non_field_errors %}
      <p class="errornote">
        {{ error }}
      </p>
    {% endfor %}
  {% endif %}

  <div id="content-main">

    {% if user.is_authenticated %}
      <p class="errornote">
        {% blocktranslate trimmed %}
          You are authenticated as {{ username }}, but are not authorized to
          access this page. Would you like to login to a different account?
        {% endblocktranslate %}
      </p>
    {% endif %}

    <form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
      <div class="form-row">
        {{ form.username.errors }}
        {{ form.username.label_tag }} {{ form.username }}
      </div>
      <div class="form-row">
        {{ form.password.errors }}
        {{ form.password.label_tag }} {{ form.password }}
        <input type="hidden" name="next" value="{{ next }}">
      </div>
      <div class="form-row">
        {{ form.captcha.errors }}
        {{ form.captcha }}
      </div>
      <div class="password-reset-link">
        <a href="{% url 'accounts:password_reset' %}">{% translate 'Forgotten your password or username?' %}</a>
      </div>
      <br>
      {% url 'account_login' as account_login %}{% if account_login %}
        <div class="password-reset-link">
          <a href="{{ account_login }}">{% translate 'Or you want to sign up a new account?' %}</a>
        </div>
      {% endif %}
      <div class="submit-row">
        <input type="submit" value="{% translate 'Log in' %}">
      </div>
    </form>

  </div>
{% endblock %}
