{% extends 'aapayout/base.html' %}
{% load i18n %}
{% load humanize %}
{% load aapayout_filters %}

{% block details %}
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-12">
            <h2>{% translate "Mark Payout as Paid" %}</h2>
        </div>
    </div>

    <div class="row">
        <div class="col-md-8">
            <!-- Payout Information -->
            <div class="card mb-4">
                <div class="card-header bg-primary text-white">
                    <h5>{% translate "Payout Information" %}</h5>
                </div>
                <div class="card-body">
                    <dl class="row">
                        <dt class="col-sm-3">{% translate "Recipient" %}:</dt>
                        <dd class="col-sm-9">{{ payout.recipient.name }}</dd>

                        <dt class="col-sm-3">{% translate "Amount" %}:</dt>
                        <dd class="col-sm-9"><strong class="text-primary">{{ payout.amount|isk_format_full }}</strong></dd>

                        <dt class="col-sm-3">{% translate "Fleet" %}:</dt>
                        <dd class="col-sm-9">
                            <a href="{% url 'aapayout:fleet_detail' payout.loot_pool.fleet.pk %}">
                                {{ payout.loot_pool.fleet.name }}
                            </a>
                        </dd>

                        <dt class="col-sm-3">{% translate "Loot Pool" %}:</dt>
                        <dd class="col-sm-9">
                            <a href="{% url 'aapayout:loot_detail' payout.loot_pool.pk %}">
                                {{ payout.loot_pool.name }}
                            </a>
                        </dd>

                        <dt class="col-sm-3">{% translate "Current Status" %}:</dt>
                        <dd class="col-sm-9">
                            <span class="badge bg-warning text-dark">{{ payout.get_status_display }}</span>
                        </dd>

                        <dt class="col-sm-3">{% translate "Created" %}:</dt>
                        <dd class="col-sm-9">{{ payout.created_at|date:"Y-m-d H:i" }}</dd>
                    </dl>
                </div>
            </div>

            <!-- Payment Form -->
            <div class="card">
                <div class="card-header bg-success text-white">
                    <h5>{% translate "Payment Details" %}</h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}

                        {% if form.non_field_errors %}
                        <div class="alert alert-danger">
                            {{ form.non_field_errors }}
                        </div>
                        {% endif %}

                        <div class="mb-3">
                            <label for="{{ form.payment_method.id_for_label }}" class="form-label">
                                {{ form.payment_method.label }} <span class="text-danger">*</span>
                            </label>
                            {{ form.payment_method }}
                            {% if form.payment_method.errors %}
                                <div class="text-danger">{{ form.payment_method.errors }}</div>
                            {% endif %}
                        </div>

                        <div class="mb-3">
                            <label for="{{ form.transaction_reference.id_for_label }}" class="form-label">
                                {{ form.transaction_reference.label }}
                            </label>
                            {{ form.transaction_reference }}
                            {% if form.transaction_reference.errors %}
                                <div class="text-danger">{{ form.transaction_reference.errors }}</div>
                            {% endif %}
                            {% if form.transaction_reference.help_text %}
                                <small class="form-text text-muted">{{ form.transaction_reference.help_text }}</small>
                            {% endif %}
                        </div>

                        <div class="mb-3">
                            <label for="{{ form.notes.id_for_label }}" class="form-label">
                                {{ form.notes.label }}
                            </label>
                            {{ form.notes }}
                            {% if form.notes.errors %}
                                <div class="text-danger">{{ form.notes.errors }}</div>
                            {% endif %}
                        </div>

                        <div class="alert alert-info">
                            <i class="fas fa-info-circle"></i>
                            {% translate "This will mark the payout as paid and record you as the payer. The payment timestamp will be automatically recorded." %}
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="{% url 'aapayout:payout_list' payout.loot_pool.pk %}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left"></i> {% translate "Cancel" %}
                            </a>
                            <button type="submit" class="btn btn-success btn-lg">
                                <i class="fas fa-check"></i> {% translate "Mark as Paid" %}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card border-info">
                <div class="card-header bg-info text-white">
                    <h5>{% translate "Payment Methods" %}</h5>
                </div>
                <div class="card-body">
                    <h6>{% translate "Available Methods" %}</h6>
                    <ul class="small">
                        <li><strong>{% translate "Manual" %}:</strong> {% translate "Direct ISK transfer in-game" %}</li>
                        <li><strong>{% translate "Contract" %}:</strong> {% translate "EVE contract payment" %}</li>
                        <li><strong>{% translate "Wallet Journal" %}:</strong> {% translate "Recorded in wallet journal" %}</li>
                    </ul>
                    <hr>
                    <h6>{% translate "Best Practices" %}</h6>
                    <ul class="small">
                        <li>{% translate "Always provide a transaction reference" %}</li>
                        <li>{% translate "Take a screenshot for records" %}</li>
                        <li>{% translate "Verify character name before sending ISK" %}</li>
                        <li>{% translate "Add notes if there are any issues" %}</li>
                    </ul>
                    <hr>
                    <h6>{% translate "Quick Tips" %}</h6>
                    <p class="small">
                        {% translate "For manual payments, copy the character name and amount carefully. Double-check before confirming the transfer in EVE." %}
                    </p>
                </div>
            </div>

            <div class="card border-warning mt-3">
                <div class="card-header bg-warning text-dark">
                    <h5>{% translate "Important" %}</h5>
                </div>
                <div class="card-body">
                    <p class="small">
                        <i class="fas fa-exclamation-triangle"></i>
                        {% translate "This action cannot be easily undone. Make sure you have actually sent the ISK before marking this payout as paid." %}
                    </p>
                    <p class="small mb-0">
                        {% translate "Your username and the current timestamp will be recorded as proof of payment." %}
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
