{#
    One forum table.

    🚨 This existed twice, written out verbatim — once for the uncategorised
    forums and once inside the category loop. Sixty duplicated lines is why the
    inline styles multiplied: a change had to be made in two places and only
    ever got made in one. The duplication was the bug; the styles were the
    symptom.

    Expects $rows.
#}
<table class="table">
    <thead>
        <tr>
            <th class="col-order">Order</th>
            <th>Forum</th>
            <th>Type</th>
            <th class="num">Topics</th>
            <th class="num">Posts</th>
            <th class="col-actions">Actions</th>
        </tr>
    </thead>
    <tbody>
        @each ($rows as $forum)
        <tr>
            <td>
                <div class="reorder-controls">
                    <form method="POST" action="/admin/forums/{{ $forum['id'] }}/move-up" class="inline-form">
                        @csrf
                        <button type="submit" class="reorder-btn" title="Move up" aria-label="Move {{ $forum['title'] }} up">&uarr;</button>
                    </form>
                    <form method="POST" action="/admin/forums/{{ $forum['id'] }}/move-down" class="inline-form">
                        @csrf
                        <button type="submit" class="reorder-btn" title="Move down" aria-label="Move {{ $forum['title'] }} down">&darr;</button>
                    </form>
                </div>
            </td>
            <td>
                <a href="/admin/forums/{{ $forum['id'] }}/edit" class="admin-cell-title">{{ $forum['title'] }}</a>
                @notempty($forum['description'] ?? '')
                <div class="admin-cell-note">{{ $forum['description'] }}</div>
                @endnotempty
            </td>
            <td><span class="type-badge type-{{ $forum['type'] }}">{{ $forum['type'] }}</span></td>
            <td class="num">{{ number_format((int) $forum['topic_count']) }}</td>
            <td class="num">{{ number_format((int) $forum['post_count']) }}</td>
            <td>
                <div class="admin-row-actions">
                    <a href="/admin/forums/{{ $forum['id'] }}/edit" class="btn btn-default btn-sm">Edit</a>
                    {#
                        Delete is offered only when there is nothing to lose.
                        A forum with topics in it is not something to remove
                        behind a confirm dialog.
                    #}
                    @if ((int) $forum['topic_count'] === 0)
                    <form method="POST" action="/admin/forums/{{ $forum['id'] }}/delete" class="inline-form"
                          onsubmit="return confirm('Delete {{ $forum['title'] }}? This cannot be undone.')">
                        @csrf
                        <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                    </form>
                    @endif
                </div>
            </td>
        </tr>
        @endeach
    </tbody>
</table>
