{* Aktivität tab — "what happened?", in two sub-views (design §2, ledger U4).

   The sub-nav is plain links, not HTMX: both views are full-page reads, one of them handles an undo
   POST, and the links already have to carry `cPluginTab` anyway. See Controller/Activity.php.

   Tailwind only, via `$ui` (adminmenu/Controller/Ui.php). *}
<div class="tnt-mcp-activity py-4">

    <nav class="mb-4 flex flex-wrap gap-2" aria-label="{if $lang == 'en'}Activity views{else}Aktivitäts-Ansichten{/if}">
        <a href="{$requestsUrl|escape}"
           {if $view === 'requests'}aria-current="page"{/if}
           class="rounded-md px-3 py-1.5 text-sm font-medium
                  {if $view === 'requests'}bg-sky-500/10 text-sky-700 dark:bg-sky-400/10 dark:text-sky-300
                  {else}text-gray-600 hover:bg-gray-500/10 dark:text-gray-300{/if}">
            {if $lang == 'en'}Requests{else}Anfragen{/if}
        </a>
        <a href="{$changesUrl|escape}"
           {if $view === 'changes'}aria-current="page"{/if}
           class="rounded-md px-3 py-1.5 text-sm font-medium
                  {if $view === 'changes'}bg-sky-500/10 text-sky-700 dark:bg-sky-400/10 dark:text-sky-300
                  {else}text-gray-600 hover:bg-gray-500/10 dark:text-gray-300{/if}">
            {if $lang == 'en'}Changes{else}Änderungen{/if}
        </a>
    </nav>

    {* Already-rendered HTML from this plugin's own template — see Controller/Activity.php for why
       it is composed in PHP rather than with {include}. *}
    {$subView nofilter}

    {* The outcome tally used to open Server-Status, where a merchant met `denied:mode 23` before
       anything told them what the plugin was for (design §6.3). It is debugging, so it lives at the
       bottom of the activity tab, collapsed. *}
    {if $auditSummary}
        <details class="group {$ui.card} mt-2 p-4">
            <summary class="flex cursor-pointer list-none items-center gap-2 text-sm font-semibold
                            text-gray-900 dark:text-gray-100">
                <svg class="h-4 w-4 shrink-0 text-gray-400 transition-transform group-open:rotate-90"
                     viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                     stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                    <path d="m9 18 6-6-6-6"></path>
                </svg>
                {if $lang == 'en'}Audit summary (by result){else}Audit-Zusammenfassung (nach Ergebnis){/if}
            </summary>
            <div class="{$ui.tableWrap} {$ui.tableScroll} mt-3">
                <table class="{$ui.table}">
                    <thead>
                    <tr>
                        <th class="{$ui.thSticky}">{if $lang == 'en'}Result{else}Ergebnis{/if}</th>
                        <th class="{$ui.thSticky} text-right">{if $lang == 'en'}Count{else}Anzahl{/if}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $auditSummary as $row}
                        <tr>
                            <td class="{$ui.td}"><span class="{$ui.chip[$row.tone]}">{$row.label|escape}</span></td>
                            <td class="{$ui.td} text-right">{$row.count|intval}</td>
                        </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </details>
    {/if}
</div>
