{% extends "allauth/layouts/entrance.html" %}
{% load i18n account %}

{% block title %}
    {% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}
{% endblock %}

{% block body_inner %}
<div class="bg-white max-w-md w-full sm:border sm:border-gray-200 sm:rounded-xl sm:shadow-2xs">
  <div class="p-8">
    <h1 class="text-center text-2xl font-bold text-gray-900">
        {% if token_fail %}
            {% trans "Bad Token" %}
        {% else %}
            {% trans "Set New Password" %}
        {% endif %}
    </h1>

    {% if token_fail %}
        {% url 'account_reset_password' as passwd_reset_url %}
        <p class="mt-4 text-center text-sm text-red-600">
            {% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a <a href="{{ passwd_reset_url }}" class="font-medium text-blue-600 hover:text-blue-500">new password reset</a>.{% endblocktrans %}
        </p>
    {% else %}
        <form method="post" action="{{ action_url }}" class="mt-6 space-y-4">
            {% csrf_token %}
            
            {{ form.non_field_errors }}

            {% for field in form.visible_fields %}
            <div>
                <label for="{{ field.id_for_label }}" class="block text-sm mb-1">{{ field.label }}</label>
                <input id="{{ field.id_for_label }}" name="{{ field.name }}" type="{{ field.field.widget.input_type }}" required
                       class="block w-full rounded-lg border border-gray-200 px-4 py-2.5
                              focus:border-blue-500 focus:ring-blue-500 sm:text-sm"
                       placeholder="{{ field.label }}"
                       {% if field.errors %}aria-describedby="{{ field.id_for_label }}-error"{% endif %}
                       {% if field.help_text %}aria-describedby="{{ field.id_for_label }}-help"{% endif %}>
                {% if field.help_text %}
                  <p class="mt-1 text-xs text-gray-500" id="{{ field.id_for_label }}-help">{{ field.help_text|safe }}</p>
                {% endif %}
                {% if field.errors %}
                  <p class="mt-1 text-sm text-red-600" id="{{ field.id_for_label }}-error">{{ field.errors|striptags }}</p>
                {% endif %}
            </div>
            {% endfor %}

            <button type="submit" name="action"
                    class="w-full rounded-lg bg-blue-600 py-3 text-sm font-medium text-white
                           hover:bg-blue-700">
                {% trans "Change Password" %}
            </button>
        </form>
    {% endif %}
  </div>
</div>
{% endblock %} 