{% extends 'base.html' %}
{% load static %}

{% block head %}
    <style>
        body {
            background-color: #0F4C85;
        }

        .login {
            background-color: #F7F7F7;
            border-radius: 2px;
            box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3)
        }

        .btn, .form-control {
            border-radius: 0;
        }
    </style>

    <script>
        $(function() {
            $('#register-mode').click(function() {
                $('#login-form').collapse('hide');
                $('#register-form').collapse('show');
                $('#reset-form').collapse('hide');
            });

            $('#login-mode').click(function() {
                $('#login-form').collapse('show');
                $('#register-form').collapse('hide');
                $('#reset-form').collapse('hide');
            });

            $('#forgot-password').click(function() {
                $('#login-form').collapse('hide');
                $('#register-form').collapse('hide');
                $('#reset-form').collapse('show');
            });

            {% if failed %}
                $('#login-form input[name="username"]').css('border-color', '#ff0000').effect('shake');
                $('#login-form input[name="password"]').css('border-color', '#ff0000').effect('shake');
            {% endif %}
        });
    </script>
{% endblock %}

{% block body %}
    <div class="col-sm-11 col-md-6 col-lg-4 col-xl-2 mx-auto mt-5 p-5 login">
        <div class="form">
            <div class="my-4">
                <img src="{% static 'main/img/logo.png' %}" height="30px" width="auto">
                <a class="navbar-brand text-dark-primary" href="{% url 'home' %}" style="vertical-align: sub">
                    OACPL
                    <div class="d-inline-block d-sm-none">
                        OACPL
                    </div>
                </a>
            </div>

            <form id="login-form" class="collapse show" method="post">
                {% csrf_token %}
                <input type="hidden" name="request" value="login">
                <input type="text" class="form-control mb-2 p-2" name="username" placeholder="Username"/>
                <input type="password" class="form-control mb-2 p-2" name="password" placeholder="Password"/>
                <button class="btn btn-primary col-12 mb-2 p-2">login</button>
                <p class="d-inline-block text-muted curs-pointer"><a id="register-mode">Register</a></p>
                {% if failed %}
                    <p class="d-inline-block text-muted curs-pointer float-right"><a id="forgot-password">Forgot Password</a></p>
                {% endif %}
            </form>

            <form id="register-form" class="collapse" method="post">
                {% csrf_token %}
                <input type="hidden" name="request" value="register">
                <input type="text" class="form-control mb-2 p-2" name="username" placeholder="Username"/>
                <input type="text" class="form-control mb-2 p-2" name="email" placeholder="Email"/>
                <input type="password" class="form-control mb-2 p-2" name="password" placeholder="Password"/>
                <input type="password" class="form-control mb-2 p-2" placeholder="Confirm Password"/>
                <div class="col-12 px-0">
                    <input id="newsletter" type="checkbox" class="mb-2 curs-pointer" name="newsletter">
                    <label for="newsletter" class="curs-pointer">Newsletter</label>
                </div>
                <div class="col-12 px-0">
                    <input id="caselaw" type="checkbox" class="mb-2 curs-pointer" name="caselaw">
                    <label for="caselaw" class="curs-pointer">Case Law Access</label>
                </div>
                <button class="btn btn-primary col-12 mb-2 p-2">Register</button>
                <p class="text-muted curs-pointer"><a id="login-mode">Login</a></p>
            </form>

            <form id="reset-form" class="collapse" method="post">
                {% csrf_token %}
                <input type="text" class="form-control mb-2 p-2" name="email" placeholder="Email"/>
                <button class="btn btn-primary col-12 mb-2 p-2">Reset</button>
            </form>
        </div>
    </div>
{% endblock %}
