{% extends "base.html" %}

{% load account_tags %}
{% load i18n %}

{% block title %}{% trans "Log in" %}{% endblock %}

{% block content %}
<div class="uk-flex uk-flex-center uk-margin-large-top" uk-grid>

  <div class="uk-width-medium">
  <div class="uk-card uk-card-default uk-card-body uk-margin">
      <legend class="uk-legend">{% trans "Guest access" %}</legend>
      <div class="uk-text-meta uk-margin">Quick access for downloading
      product images and making one-off catalogs.</div>
      <a href="{% url 'login_guest' %}" class="uk-button uk-button-primary">{% trans "Log in as guest" %}</a>
  </div>
  </div>

  <div class="uk-width-medium">
  <div class="uk-card uk-card-default uk-card-body uk-margin">

    <form method="POST" action="{% url "account_login" %}"
          autocapitalize="off"
          class="uk-form"
          {% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
      <legend class="uk-legend">{% trans "Log in" %}</legend>
      {% csrf_token %}

      <div class="uk-margin">
        <div class="uk-inline uk-form-width-medium">
          <span class="uk-form-icon" uk-icon="icon: user"></span>
          <input class="uk-input"
                 type="text" name="username" id="id_username"
                 maxlength="30" required
                 placeholder="{% trans 'Username' %}">
        </div>
      </div>

      <div class="uk-margin">
        <div class="uk-inline uk-form-width-medium">
          <span class="uk-form-icon" uk-icon="icon: lock"></span>
          <input class="uk-input"
                 type="password" name="password" id="id_password"
                 required
                 placeholder="{% trans 'Password' %}">
        </div>
      </div>

      <div class="uk-margin uk-form-width-medium">
        <input class="uk-checkbox" type="checkbox" name="remember" id="id_remember">
        <label class="uk-form-label" for="id_remember">Remember Me</label>
      </div>

      {% if redirect_field_value %}
      <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
      {% endif %}

      <button type="submit" class="uk-button uk-button-primary">{% trans "Log in" %}</button>
    </form>

    <p>
      <small>
        <a href="{% url "account_password_reset" %}" class="btn btn-link">{% trans "Forgot your password?" %}</a>
        <br/>
        {% if ACCOUNT_OPEN_SIGNUP %}
        {% trans "Don't have an account?" %}  <strong><a href="{% urlnext 'account_signup' %}">{% trans "Sign up" %}</a></strong>
        {% endif %}
      </small>
    </p>

  </div>
  </div>
</div>
{% endblock %}

{% block scripts %}
    {{ block.super }}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#id_username').focus();
        });
    </script>
{% endblock %}
