{% load i18n %}
<table class="table table-striped align-middle">
    <thead><tr>
        <th></th><th>{% trans "Name" %}</th><th>{% trans "Group" %}</th>
        <th>{% trans "Stock" %}</th><th>{% trans "Price" %}</th><th></th>
    </tr></thead>
    <tbody>
    {% for listing in listings %}
        <tr>
            <td class="text-nowrap">
                <img src="https://images.evetech.net/types/{{ listing.eve_type.id }}/icon?size=32" alt="" width="32" height="32">
                <form method="post" action="{% url 'backoffice:toggle_featured' shop.pk listing.pk %}" class="d-inline">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-sm btn-link p-0 ms-1 align-middle"
                            title="{% if listing.featured %}{% trans 'Unstar' %}{% else %}{% trans 'Star (feature on storefront)' %}{% endif %}">
                        <i class="{% if listing.featured %}fa-solid fa-star text-warning{% else %}fa-regular fa-star text-muted{% endif %}"></i>
                    </button>
                </form>
            </td>
            <td>{{ listing.eve_type.name }}</td>
            <td>{{ listing.eve_type.eve_group.name }}</td>
            <td>
                <span class="d-inline-flex align-items-center gap-1">
                    <span class="text-end" style="min-width:2.5ch">{{ listing.stock }}</span>
                    {% if listing.stock_mode == 'fixed' %}<span class="badge bg-warning text-dark" title="{% trans 'Manual stock (not auto-tracked)' %}">M</span>{% endif %}
                    {% if listing.persist %}<span class="badge bg-info" title="{% trans 'Persists when out of stock' %}">P</span>{% endif %}
                </span>
            </td>
            <td>{{ listing.price_display }} <span class="badge bg-secondary">{{ listing.price_mode_display }}</span></td>
            <td class="text-end">
                <button type="button" class="btn btn-sm btn-outline-theme edit-hull-btn"
                        data-url="{% url 'backoffice:edit_hull' shop.pk listing.pk %}"
                        data-name="{{ listing.eve_type.name }}"
                        data-stock-mode="{{ listing.stock_mode }}"
                        data-stock="{{ listing.stock }}"
                        data-price-mode="{{ listing.price_mode }}"
                        data-price="{{ listing.price }}"
                        data-price-pct="{{ listing.price_pct|default_if_none:'' }}"
                        data-persist="{{ listing.persist|yesno:'1,0' }}"
                        data-description="{{ listing.description }}">
                    <i class="fa-solid fa-pen-to-square fa-fw"></i> {% trans "Edit" %}
                </button>
                <form method="post" action="{% url 'backoffice:remove_hull' shop.pk listing.pk %}" class="d-inline">
                    {% csrf_token %}
                    <button class="btn btn-sm btn-outline-danger">{% trans "Remove" %}</button>
                </form>
            </td>
        </tr>
    {% empty %}
        <tr><td colspan="6" class="text-muted">{% trans "No hulls listed yet." %}</td></tr>
    {% endfor %}
    </tbody>
</table>
