{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Forgot Password</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
    
    <style>
        body {
            font-family: 'Poppins', sans-serif;
            background-color: #f8f9fa;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .container {
            max-width: 900px;
            background: #fff;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border-radius: 15px;
            overflow: hidden;
        }

        .row {
            display: flex;
            align-items: stretch;
        }

        .left-section {
            background: url("{% static 'img/login2.jpg' %}") no-repeat center center/cover;
            min-height: 400px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #fff;
            padding: 40px;
        }

        .right-section {
            padding: 60px;
        }

        .title {
            font-weight: bold;
            font-size: 24px;
            color: #333;
            text-align: center;
        }

        .form-control {
            background: rgba(0, 0, 0, 0.05);
            border: none;
            padding: 10px;
            font-size: 16px;
        }

        .form-control:focus {
            box-shadow: none;
            border: 2px solid #6222CC;
        }

        .btn-primary {
            background: #6222CC;
            border: none;
            padding: 12px;
            font-size: 16px;
            width: 100%;
            transition: 0.3s;
        }

        .btn-primary:hover {
            background: #6222CC;
        }

        .text-primary {
            color: #6222CC;
            text-decoration: none;
        }

        .text-primary:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>

<div class="container">
    <div class="row">
        <div class="col-md-6 left-section"></div>

        <div class="col-md-6 right-section">
            <h3 class="title mb-4">Forgot Password</h3>
            <p class="text-center text-muted">Enter your email to receive an OTP and reset your password.</p>

            {% if messages %}
                {% for message in messages %}
                    <div class="alert {% if message.tags == 'error' %}alert-danger{% else %}alert-success{% endif %} text-center" role="alert">
                        {{ message }}
                    </div>
                {% endfor %}
            {% endif %}

            <form method="POST" class="needs-validation" novalidate>
                {% csrf_token %}
                <div class="mb-3">
                    <label for="email" class="form-label">Email Address</label>
                    <input type="email" class="form-control" id="email" name="email" placeholder="Enter your email" required>
                    <div class="invalid-feedback">Please enter a valid email address.</div>
                </div>
                <button type="submit" class="btn btn-primary">Send OTP</button>
            </form>

            <p class="mt-3">
                <a href="{% url 'loginview' %}" class="text-primary">Back to Login</a>
            </p>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
    (function () {
        'use strict';
        var forms = document.querySelectorAll('.needs-validation');
        Array.prototype.slice.call(forms).forEach(function (form) {
            form.addEventListener('submit', function (event) {
                if (!form.checkValidity()) {
                    event.preventDefault();
                    event.stopPropagation();
                }
                form.classList.add('was-validated');
            }, false);
        });
    })();
</script>
</body>
</html>
