<?php $h=static fn($v):string=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8');$r=is_array($report??null)?$report:[];$policies=$r['policies']??[];$decisions=$r['decisions']??[]; ?>
<style>.zt{display:grid;gap:16px}.zt-card{background:#fff;border:1px solid #dce4ef;border-radius:16px;padding:18px}.zt-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px}.zt input,.zt select,.zt textarea{width:100%;box-sizing:border-box;padding:9px;border:1px solid #ccd8e6;border-radius:8px}.zt label{display:grid;gap:5px}.zt-btn{border:0;border-radius:9px;padding:9px 12px;background:#1d5f9f;color:#fff;font-weight:700;text-decoration:none}.zt-muted{background:#edf3f9;color:#173c62}.zt-table{width:100%;border-collapse:collapse}.zt-table th,.zt-table td{padding:9px;border-bottom:1px solid #e7edf5;text-align:left;white-space:nowrap}.zt-scroll{overflow:auto}.zt-badge{padding:4px 8px;border-radius:999px;background:#edf3f9}</style>
<div class="zt"><div><a class="zt-btn zt-muted" href="/public/administration/securite/soc">← SOC</a></div><section class="zt-card"><small>ENTERPRISE-008.8 · AXIOM 9.9.4</small><h1>Zero Trust Policy Engine</h1><p>Politiques conditionnelles, score de confiance, MFA adaptatif, plages horaires et simulation avant activation.</p></section>
<?php if(isset($simulation)):?><section class="zt-card"><h2>Résultat de simulation</h2><p><strong><?= $h(strtoupper((string)$simulation['decision'])) ?></strong> — <?= $h($simulation['reason']) ?> (score <?= (int)$simulation['score'] ?>/100, politique <?= $h($simulation['matched']?:'aucune') ?>)</p></section><?php endif?>
<section class="zt-grid"><form class="zt-card" method="post" action="/public/administration/securite/soc/zero-trust/enregistrer"><h2>Créer ou modifier une politique</h2><label>Code<input name="code" required placeholder="privileged-access"></label><label>Nom<input name="name" required></label><label>Description<textarea name="description"></textarea></label><div class="zt-grid"><label>Priorité<input type="number" name="priority" value="100"></label><label>Effet<select name="effect"><option value="challenge">Challenge</option><option value="deny">Refuser</option><option value="allow">Autoriser</option></select></label><label>Score minimum<input type="number" min="0" max="100" name="min_trust_score" value="60"></label><label>Session max. (min)<input type="number" name="max_session_minutes" value="120"></label><label>Début autorisé<input type="time" name="allowed_hours_start"></label><label>Fin autorisée<input type="time" name="allowed_hours_end"></label><label>Module<input name="module_pattern" value="*"></label><label>Rôle<input name="role_pattern" value="*"></label></div><p><label><input type="checkbox" name="require_mfa" value="1"> MFA requise</label> <label><input type="checkbox" name="enabled" value="1" checked> Active</label> <label><input type="checkbox" name="simulation_only" value="1" checked> Simulation seulement</label></p><button class="zt-btn">Enregistrer</button></form>
<form class="zt-card" method="post" action="/public/administration/securite/soc/zero-trust/simuler"><h2>Simuler une décision</h2><label>Score de confiance<input type="number" min="0" max="100" name="trust_score" value="50"></label><label>Module<input name="module" value="administration"></label><label>Rôle<input name="role" value="super_admin"></label><label>Route<input name="route" value="/administration/securite/soc"></label><label><input type="checkbox" name="mfa" value="1"> MFA validée</label><button class="zt-btn">Simuler</button></form></section>
<section class="zt-card zt-scroll"><h2>Politiques</h2><table class="zt-table"><thead><tr><th>Priorité</th><th>Code</th><th>Effet</th><th>Score</th><th>MFA</th><th>Module</th><th>Rôle</th><th>Mode</th><th>Statut</th><th></th></tr></thead><tbody><?php foreach($policies as $p):?><tr><td><?= (int)$p['priority'] ?></td><td><strong><?= $h($p['code']) ?></strong><br><small><?= $h($p['name']) ?></small></td><td><?= $h($p['effect']) ?></td><td><?= (int)$p['min_trust_score'] ?></td><td><?= (int)$p['require_mfa']?'Oui':'Non' ?></td><td><?= $h($p['module_pattern']) ?></td><td><?= $h($p['role_pattern']) ?></td><td><?= (int)$p['simulation_only']?'Simulation':'Appliquée' ?></td><td><span class="zt-badge"><?= (int)$p['enabled']?'Active':'Inactive' ?></span></td><td><form method="post" action="/public/administration/securite/soc/zero-trust/statut"><input type="hidden" name="id" value="<?= (int)$p['id'] ?>"><button class="zt-btn zt-muted">Basculer</button></form></td></tr><?php endforeach?></tbody></table></section>
<section class="zt-card zt-scroll"><h2>Décisions récentes</h2><table class="zt-table"><thead><tr><th>Date</th><th>Décision</th><th>Score</th><th>Politique</th><th>Module</th><th>Route</th><th>Motif</th></tr></thead><tbody><?php foreach($decisions as $d):?><tr><td><?= $h($d['created_at']) ?></td><td><?= $h($d['decision']) ?></td><td><?= (int)$d['trust_score'] ?></td><td><?= $h($d['policy_code']) ?></td><td><?= $h($d['module']) ?></td><td><?= $h($d['route']) ?></td><td><?= $h($d['reason']) ?></td></tr><?php endforeach?></tbody></table></section></div>
