<?php
declare(strict_types=1);

require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/lib/omr_svg.php';

$ctx = omr_context('ficha');
$concurso = $ctx['concurso'];
$nombreConcurso = $concurso ? trim((string)$concurso['nombre'] . ' ' . (string)$concurso['subtitulo']) : 'NOBEX';

$svg = render_omr_svg([
    'titulo' => 'FICHA OMR - CONCURSO NOBEL',
    'concurso' => $nombreConcurso,
    'subtitulo' => 'Modo opcional: si no hay escaner, corregir manualmente en el sistema.',
]);
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Ficha OMR</title>
    <style>
        @page{size:A5 portrait;margin:0}
        *{box-sizing:border-box}
        body{margin:0;background:#e5e7eb;font-family:Arial,Helvetica,sans-serif}
        .toolbar{padding:12px;background:#111827;color:#fff;display:flex;gap:10px;align-items:center;justify-content:center}
        .toolbar button,.toolbar a{border:0;border-radius:8px;padding:9px 12px;font-weight:800;text-decoration:none;cursor:pointer}
        .toolbar button{background:#f5bd16;color:#111827}.toolbar a{background:#374151;color:#fff}
        .sheet{width:148mm;height:210mm;margin:12px auto;background:#fff;box-shadow:0 8px 25px rgba(0,0,0,.18)}
        .sheet svg{display:block;width:148mm;height:210mm}
        @media print{
            body{background:#fff}
            .toolbar{display:none}
            .sheet{margin:0;box-shadow:none}
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <button type="button" onclick="window.print()">Imprimir al 100%</button>
        <a href="index.php?id_concurso=<?php echo (int)$ctx['id_concurso']; ?>">Volver al OMR</a>
    </div>
    <div class="sheet"><?php echo $svg; ?></div>
</body>
</html>
