{% load static form_tags %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>NibasaViewer — Login</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
        <link href="{% static 'css/styles.css' %}" rel="stylesheet">
    </head>
    <body class="theme-{{ theme|default:'dark' }}">

        <section class="vh-100">
          <div class="container py-5 h-100">
            <div class="row d-flex justify-content-center align-items-center h-100">
              <div class="col col-xl-10">
                <div class="card shadow" style="border-radius: 1rem;">
                  <div class="row g-0">
                    <div class="col-md-6 col-lg-5 d-none d-md-block">
                      <img src="{% static 'imgs/login.jpg' %}"
                        alt="login image" class="img-fluid" style="height:100%; object-fit:cover; border-radius: 1rem 0 0 1rem;" />
                    </div>
                    <div class="col-md-6 col-lg-7 d-flex align-items-center">
                      <div class="card-body p-4 p-lg-5 text-black h-100 login-form">

                        <form method="post" action="{% url 'login' %}" class="w-100">
                          {% csrf_token %}
                          {% if form.non_field_errors %}
                            <div class="alert alert-danger">{{ form.non_field_errors }}</div>
                          {% endif %}

                          <div class="d-flex align-items-center mb-3 pb-1">
                            <img src="{% static 'imgs/logo.png' %}" alt="Logo" style="width:44px; height:44px; object-fit:contain;" class="me-3">
                            <span class="h1 fw-bold mb-0 text-light">Nibasa Viewer</span>
                          </div>

                          <h5 class="fw-normal mb-1 mt-4 pb-3" style="letter-spacing: 1px; color:var(--muted);">Sign in</h5>

                          <div class="mb-4">
                            {% render_field form.username class="form-control form-control-lg" placeholder="User name" autocomplete="username" %}
                            {% if form.username.errors %}
                              <div class="text-danger small mt-1">{{ form.username.errors|striptags }}</div>
                            {% endif %}
                          </div>

                          <div class="mb-4">
                            {% render_field form.password class="form-control form-control-lg" placeholder="Password" autocomplete="current-password" %}
                            {% if form.password.errors %}
                              <div class="text-danger small mt-1">{{ form.password.errors|striptags }}</div>
                            {% endif %}
                          </div>

                          <div class="pt-1 mb-4">
                            <button class="btn btn-dark btn-lg btn-block w-100" type="submit">LOGIN</button>
                          </div>

                          {% if next %}
                            <input type="hidden" name="next" value="{{ next }}">
                          {% endif %}
                        </form>

                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </section>

        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
    </body>
</html>
