<?php $r=$report; $e=static fn($v):string=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); ?>
<style>
.ir{display:grid;gap:16px}.ir-card{background:#fff;border:1px solid #dce4ef;border-radius:18px;padding:18px}.ir-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}.ir-value{font-size:28px;font-weight:800}.ir-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}.ir-btn{border:0;border-radius:10px;padding:9px 12px;font-weight:700;cursor:pointer;text-decoration:none;background:#eef4fb;color:#163a63}.ir-table{width:100%;border-collapse:collapse}.ir-table th,.ir-table td{padding:10px;border-bottom:1px solid #e8edf4;text-align:left;vertical-align:top}.ir-scroll{overflow:auto}.ir-pill{padding:4px 8px;border-radius:999px;font-size:12px;font-weight:800;background:#edf2f7}.ir-open{background:#fee2e2;color:#991b1b}.ir-acknowledged{background:#fef3c7;color:#92400e}.ir-resolved{background:#dcfce7;color:#166534}.ir-note{width:100%;min-width:220px;min-height:58px}.ir-select{padding:8px;border:1px solid #cbd5e1;border-radius:8px}.ir-form{display:grid;gap:8px;min-width:260px}
</style>
<div class="ir">
<div class="ir-actions"><a class="ir-btn" href="/public/administration/securite/soc?hours=<?= (int)$r['hours'] ?>">← Centre SOC</a><a class="ir-btn" href="/public/administration/securite/supervision">Supervision</a></div>
<section class="ir-card"><small>SECURITY-NATIVE-019</small><h2>Réponse aux incidents</h2><p>Qualification, prise en charge et clôture des incidents corrélés par le SOC. Aucun secret ni adresse IP n’est enregistré.</p></section>
<div class="ir-grid">
<article class="ir-card"><small>Ouverts</small><div class="ir-value"><?= (int)$r['response_counts']['open'] ?></div></article>
<article class="ir-card"><small>Pris en charge</small><div class="ir-value"><?= (int)$r['response_counts']['acknowledged'] ?></div></article>
<article class="ir-card"><small>Résolus</small><div class="ir-value"><?= (int)$r['response_counts']['resolved'] ?></div></article>
<article class="ir-card"><small>Fenêtre</small><div class="ir-value"><?= (int)$r['hours'] ?> h</div></article>
</div>
<section class="ir-card"><div class="ir-actions"><?php foreach([1,6,24,72,168] as $h): ?><a class="ir-btn" href="?hours=<?= $h ?>"><?= $h<24?$h.' h':($h/24).' j' ?></a><?php endforeach; ?></div></section>
<section class="ir-card ir-scroll"><table class="ir-table"><thead><tr><th>État</th><th>Incident</th><th>Détection</th><th>Traitement</th></tr></thead><tbody>
<?php if(!$r['response_items']): ?><tr><td colspan="4">Aucun incident dans cette fenêtre.</td></tr><?php endif; ?>
<?php foreach($r['response_items'] as $i): ?><tr>
<td><span class="ir-pill ir-<?= $e($i['status']) ?>"><?= $e(strtoupper($i['status'])) ?></span></td>
<td><strong><?= $e($i['event']) ?></strong><br><small><?= $e($i['severity']) ?> · <?= (int)$i['count'] ?> occurrence(s)<br><?= $e($i['path']) ?> · acteur <?= $e($i['actor']) ?></small></td>
<td><?= $e($i['last_at']) ?></td>
<td><form class="ir-form" method="post" action="/public/administration/securite/incidents/traiter"><input type="hidden" name="_csrf" value="<?= $e($_SESSION['_csrf'] ?? '') ?>"><input type="hidden" name="incident_id" value="<?= $e($i['id']) ?>"><input type="hidden" name="hours" value="<?= (int)$r['hours'] ?>"><select class="ir-select" name="status"><option value="open" <?= $i['status']==='open'?'selected':'' ?>>Ouvert</option><option value="acknowledged" <?= $i['status']==='acknowledged'?'selected':'' ?>>Pris en charge</option><option value="resolved" <?= $i['status']==='resolved'?'selected':'' ?>>Résolu</option></select><textarea class="ir-note" name="note" maxlength="1000" placeholder="Mesures prises, vérifications, décision…"><?= $e($i['note']) ?></textarea><button class="ir-btn" type="submit">Enregistrer</button><?php if($i['updated_at']!==''): ?><small>Dernière mise à jour : <?= $e($i['updated_at']) ?></small><?php endif; ?></form></td>
</tr><?php endforeach; ?></tbody></table></section>
</div>
