<?php use App\Core\Csrf;$h=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); ?>
<main class="cda-trash"><header><a href="/public/espaces?espace=axiom">← Retour Admin</a><h1>Corbeille administrative</h1><p>Archives classées par session. La restauration est réversible ; la suppression définitive est réservée au Super‑Admin.</p></header>
<style>.cda-trash{max-width:1180px;margin:auto;padding:24px}.trash-session{margin:22px 0;padding:18px;border:1px solid #dbe3ee;border-radius:14px;background:#fff}.trash-row{display:grid;grid-template-columns:1fr auto;gap:16px;padding:14px 0;border-top:1px solid #eef2f7}.trash-row:first-of-type{border-top:0}.trash-actions{display:flex;gap:8px;align-items:center}.trash-danger{background:#991b1b;color:#fff}.trash-meta{display:block;color:#64748b;margin-top:4px}@media(max-width:700px){.trash-row{grid-template-columns:1fr}.trash-actions{flex-wrap:wrap}}</style>
<?php if(!$groups):?><section class="trash-session"><strong>La corbeille est vide.</strong></section><?php endif?>
<?php foreach($groups as $session=>$items):?><section class="trash-session"><h2>Session <?=$h($session)?></h2><?php foreach($items as $item):?><article class="trash-row"><div><strong><?=$h($item['entity_label'])?></strong><span class="trash-meta"><?=$h($item['entity_type'])?> · <?=$h($item['archived_at'])?> · <?=$h(trim((string)$item['archived_by_name'])?:'Utilisateur inconnu')?></span><?php if($item['reason']):?><small><?=$h($item['reason'])?></small><?php endif?></div><div class="trash-actions"><form method="post" action="/public/administration/corbeille/restaurer"><?=Csrf::field()?><input type="hidden" name="trash_id" value="<?=(int)$item['id']?>"><button>Restaurer</button></form><?php if($superAdmin):?><form method="post" action="/public/administration/corbeille/supprimer" onsubmit="return confirm('Suppression définitive de la base : cette action est irréversible. Continuer ?');"><?=Csrf::field()?><input type="hidden" name="trash_id" value="<?=(int)$item['id']?>"><button class="trash-danger">Supprimer définitivement</button></form><?php endif?></div></article><?php endforeach?></section><?php endforeach?></main>
