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

{% load widget_tweaks %}

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

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

{% block usertools %}{% endblock %}

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

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block main-content-class %}{% endblock %}

{% block content %}

  <div class="container mt-5">
    <div class="row">
      <div class="col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3 col-lg-6 offset-lg-3 col-xl-4 offset-xl-4">
        {% block login-brand %}
        <div class="login-brand">
          <img src="{% static "admin/assets/img/stisla-fill.svg" %}" alt="logo" width="100" class="shadow-light rounded-circle">
        </div>
        {% endblock %}

        <div class="card card-primary">
          <div class="card-header"><h4>Login</h4></div>
          {% if form.errors and not form.non_field_errors %}
          <p class="errornote">
          {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
          </p>
          {% endif %}

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

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


          <div class="card-body">
            <form class="needs-validation" action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
              <div class="form-group">
                {{ form.username.label_tag }}
                {% render_field form.username class="form-control" %}
                <div class="invalid-feedback">
                  {{ form.username.errors }}
                </div>
              </div>

              <div class="form-group">
                <div class="d-block">
                  {{ form.password.label_tag }}
                  <div class="float-right">
                    {% url 'admin_password_reset' as password_reset_url %}
                    {% if password_reset_url %}
                    <a class="text-small" href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>                    
                    {% endif %}
                  </div>
                </div>
                {% render_field form.password class="form-control" %}                
                <input type="hidden" name="next" value="{{ next }}">
                <div class="invalid-feedback">
                  {{ form.password.errors }}
                  
                </div>
              </div>

              <!-- <div class="form-group">
                <div class="custom-control custom-checkbox">
                  <input type="checkbox" name="remember" class="custom-control-input" tabindex="3" id="remember-me">
                  <label class="custom-control-label" for="remember-me">Remember Me</label>
                </div>
              </div> -->

              <div class="form-group">
                <button type="submit" class="btn btn-primary btn-lg btn-block" tabindex="4">
                  {% trans 'Log in' %}
                </button>
              </div>
            </form>            
          </div>
        </div>        
      </div>
    </div>
  </div>
{% endblock %}
