{% extends 'base.html' %}

{% block title %}Set New Password - Referral Rewards{% endblock %}

{% block content %}
<div class="container py-5 mt-5">
    <div class="row justify-content-center">
        <div class="col-md-5">
            <div class="card border-0 shadow-lg p-4 p-md-5 rounded-4">
                <div class="text-center mb-4">
                    <h2 class="mb-3">Set New Password</h2>
                    <p class="text-muted">Please enter your new password twice so we can verify you typed it correctly.</p>
                </div>
                
                {% if validlink %}
                    <form method="post">
                        {% csrf_token %}
                        {% if form.errors %}
                            <div class="alert alert-danger">
                                Please correct the errors below.
                            </div>
                        {% endif %}
                        
                        {% for field in form %}
                            <div class="mb-3">
                                <label for="{{ field.id_for_label }}" class="form-label fw-600">{{ field.label }}</label>
                                {{ field }}
                                {% if field.help_text %}
                                    <div class="form-text small">{{ field.help_text }}</div>
                                {% endif %}
                                {% if field.errors %}
                                    <div class="text-danger small mt-1">
                                        {{ field.errors }}
                                    </div>
                                {% endif %}
                            </div>
                        {% endfor %}
                        
                        <button type="submit" class="btn btn-primary w-100 py-3 mt-4">Change My Password</button>
                    </form>
                {% else %}
                    <div class="alert alert-danger">
                        The password reset link was invalid, possibly because it has already been used. Please request a new password reset.
                    </div>
                    <a href="{% url 'password_reset' %}" class="btn btn-primary w-100 py-3 mt-4">Request New Link</a>
                {% endif %}
            </div>
        </div>
    </div>
</div>

<style>
    /* Styling for Django generated form fields */
    input[type="password"] {
        display: block;
        width: 100%;
        padding: 0.375rem 0.75rem;
        font-size: 1rem;
        font-weight: 400;
        line-height: 1.5;
        color: #212529;
        background-color: #fff;
        background-clip: padding-box;
        border: 1px solid #ced4da;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 0.375rem;
        transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    }
</style>
{% endblock %}
