{% load aa_forum %}
{% load i18n %}
{% load django_bootstrap5 %}

<div class="card card-default">
    <div class="card-header">
        <div class="card-title mb-0">
            {% translate "Reply" %}
        </div>
    </div>

    <div class="card-body">
        {% if page_obj.has_next %}
            <div class="alert alert-warning">
                {% translate "Note: You are not on the last page of this topic and may miss the most recent replies." %}
            </div>
        {% endif %}

        {% if topic.is_locked %}
            <div class="alert alert-danger">
                {% translate "Warning: this topic is locked! Only admins can reply." %}
            </div>
        {% endif %}

        <form id="aa-forum-form-message-reply" autocomplete="off" action="{% url 'aa_forum:forum_topic_reply' topic.board.category.slug topic.board.slug topic.slug %}" method="post">
            {% csrf_token %}

            {% bootstrap_field reply_form.message %}

            {% if topic.first_message.user_created == request.user or perms.aa_forum.manage_forum %}
                {% if not topic.is_locked %}
                    {% bootstrap_field reply_form.close_topic %}
                {% endif %}

                {% if topic.is_locked and perms.aa_forum.manage_forum %}
                    {% bootstrap_field reply_form.reopen_topic %}
                {% endif %}
            {% endif %}

            {% include "aa_forum/partials/form/required-field-hint.html" %}

            <div class="form-group aa-forum-form-group aa-forum-form-reply float-end clearfix">
                <button class="btn btn-secondary btn-sm" type="reset">
                    {% translate "Clear form" %}
                </button>

                <button class="btn btn-primary btn-sm" type="submit">
                    {% translate "Reply" %}
                </button>
            </div>
        </form>
    </div>
</div>
