<?php
$row = is_array($enterprisePrintReport ?? null) ? $enterprisePrintReport : [];
$report = is_array($row['report'] ?? null) ? $row['report'] : [];
$scores = (array)($report['scores'] ?? []);
$manifest = (array)($report['manifest'] ?? []);
$h = static fn($v): string => htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
?>
<style>body{font-family:Arial,sans-serif;color:#14233c;margin:32px}header{border-bottom:3px solid #235f9d;padding-bottom:18px;margin-bottom:22px}.grid{display:grid;grid-template-columns:repeat(5,1fr);gap:10px}.card{border:1px solid #d8e2ee;border-radius:12px;padding:14px;margin:12px 0}.score{font-size:24px;font-weight:800}.decision{display:inline-block;padding:8px 12px;border-radius:99px;background:#eaf2fb;font-weight:800}table{width:100%;border-collapse:collapse}th,td{padding:9px;border-bottom:1px solid #ddd;text-align:left}@media print{button{display:none}body{margin:15mm}}</style>
<header><small>AXIOM PLATFORM-023.2.5</small><h1>Enterprise Compatibility Report</h1><p><?= $h($manifest['package']??$row['nom_package']??'') ?> · <?= $h($manifest['version']??$row['version_cible']??'') ?></p><span class="decision"><?= $h($report['decision']??'') ?></span></header>
<button onclick="window.print()">Imprimer / Enregistrer en PDF</button>
<div class="grid"><?php foreach(['global'=>'Global','trust'=>'Trust','compatibility'=>'Compatibilité','certification'=>'Certification','policy'=>'Politique'] as $k=>$label): ?><div class="card"><strong><?= $h($label) ?></strong><div class="score"><?= (int)($scores[$k]??0) ?>/100</div></div><?php endforeach; ?></div>
<section class="card"><h2>Identité</h2><table><tr><th>Package</th><td><?= $h($manifest['package']??'') ?></td></tr><tr><th>UUID</th><td><?= $h($manifest['package_uuid']??'') ?></td></tr><tr><th>Révision</th><td><?= $h($manifest['package_revision']??'') ?></td></tr><tr><th>Éditeur</th><td><?= $h($manifest['publisher']??'') ?></td></tr><tr><th>Build</th><td><?= $h($manifest['build_number']??'') ?></td></tr><tr><th>Analysé le</th><td><?= $h($report['evaluated_at']??$row['created_at']??'') ?></td></tr></table></section>
<?php foreach(['issues'=>'Blocages','warnings'=>'Avertissements','risks'=>'Risques'] as $key=>$title): ?><section class="card"><h2><?= $title ?></h2><ul><?php foreach((array)($report[$key]??[]) as $x): ?><li><?= $h($x) ?></li><?php endforeach; ?><?php if(empty($report[$key])):?><li>Aucun.</li><?php endif;?></ul></section><?php endforeach; ?>
