{% extends "base.html" %}
{% block content %}

<div class="min-h-screen bg-[color:var(--color-primary-contrast)]">
    <div class="max-w-4xl mx-auto px-4 py-10">

        <div class="mb-8">
            <h1 class="text-2xl font-bold text-[color:var(--color-text)] mb-2">Expense Details</h1>
            <div class="w-16 h-1 bg-[color:var(--color-accent)]"></div>
            <p class="text-lg text-[color:var(--color-text-muted)] mt-4">{{ expense.description }}</p>
        </div>

        <div class="bg-[color:var(--color-bg)] border border-[color:var(--color-border)] rounded-lg shadow-sm">

            <div class="p-6 space-y-6">

                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <p class="text-sm text-[color:var(--color-text-muted)] font-semibold mb-1">Transaction Date</p>
                        <p class="text-base text-[color:var(--color-text)]">{{ expense.date }}</p>
                    </div>

                    <div>
                        <p class="text-sm text-[color:var(--color-text-muted)] font-semibold mb-1">Quarter</p>
                        <p class="text-base text-[color:var(--color-text)]">{{ expense.quarter }}</p>
                    </div>
                </div>

                <div>
                    <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Description</p>
                    <p class="text-base text-[color:var(--color-text)]">{{ expense.description }}</p>
                </div>

                <div>
                    <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Category</p>
                    <p class="text-base text-[color:var(--color-text)]">{{ expense.category.name }}</p>
                </div>

                <div>
                    <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Supplier</p>
                    <p class="text-base text-[color:var(--color-text)]">
                        {% if expense.supplier_name %}{{ expense.supplier_name }}{% else %}
                        <span class="italic text-[color:var(--color-text-muted)]">Not specified</span>{% endif %}
                    </p>
                </div>

                <div class="bg-[color:var(--color-bg-muted)] p-4 rounded border border-[color:var(--color-border)]">
                    <h3 class="font-bold text-sm text-[color:var(--color-text)] mb-4">Financial Details</h3>

                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div>
                            <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Net Amount</p>
                            <p class="text-xl font-bold text-red-600">£{{ expense.amount }}</p>
                        </div>

                        <div>
                            <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">VAT Amount</p>
                            <p class="text-xl text-[color:var(--color-text)]">£{{ expense.vat_amount }}</p>
                            <p class="text-xs text-[color:var(--color-text-muted)] mt-1">({{ expense.vat_rate }}% rate)</p>
                        </div>

                        <div>
                            <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Total</p>
                            <p class="text-xl font-bold text-[color:var(--color-text)]">£{{ total|floatformat:2 }}</p>
                        </div>
                    </div>
                </div>

                {% if expense.notes %}
                <div class="mt-4">
                    <p class="text-sm font-semibold text-[color:var(--color-text-muted)] mb-1">Notes</p>
                    <p class="bg-[color:var(--color-bg-muted)] p-3 rounded border border-[color:var(--color-border)]
                              text-[color:var(--color-text)]">
                        {{ expense.notes }}
                    </p>
                </div>
                {% endif %}
            </div>

            <div class="bg-[color:var(--color-bg-muted)] px-6 py-4 border-t border-[color:var(--color-border)]">
                <div class="flex items-center gap-4">

                    <a href="{% url 'bookkeeping:expense_edit' expense.pk %}"
                       class="px-6 py-2 bg-[color:var(--color-primary)] text-white rounded hover:bg-[color:var(--color-accent)] transition">Edit</a>

                    <a href="{% url 'bookkeeping:expense_confirm_delete' expense.pk %}"
                       class="px-6 py-2 border border-red-600 text-red-600 rounded hover:bg-red-600 hover:text-white transition">Delete</a>

                    <a href="{% url 'bookkeeping:expense_list' %}"
                       class="px-6 py-2 border border-[color:var(--color-border)] text-[color:var(--color-text)]
                              rounded hover:bg-[color:var(--color-bg)] transition">Back to Expenses</a>
                </div>
            </div>
        </div>

    </div>
</div>

{% endblock %}
