<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel narrow">
    <p class="eyebrow">Validacao publica</p>
    <h1>Validar certificado</h1>
    <p>Introduza o codigo do certificado para confirmar autenticidade.</p>

    <form class="form" method="get" action="/certificates/validate">
        <label>
            Codigo
            <input name="code" value="<?= e($code) ?>" placeholder="MC-2026-XXXXXXXX">
        </label>
        <button class="button" type="submit">Validar</button>
    </form>

    <?php if ($code !== ''): ?>
        <?php if ($certificate): ?>
            <div class="validation-result success-box">
                <span class="badge approved">Valido</span>
                <h2><?= e($certificate['certificate_number']) ?></h2>
                <p><?= e($certificate['student_name']) ?> concluiu o curso <?= e($certificate['course_title']) ?>.</p>
                <div class="detail-list one">
                    <div><span>Emitido por</span><strong><?= e($certificate['issuer_name']) ?></strong></div>
                    <div><span>Data</span><strong><?= e(format_date($certificate['issued_at'])) ?></strong></div>
                    <div><span>Codigo</span><strong><?= e($certificate['validation_code']) ?></strong></div>
                </div>
            </div>
        <?php else: ?>
            <div class="validation-result error-box">
                <span class="badge rejected">Nao encontrado</span>
                <p>Nao existe certificado activo com este codigo.</p>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
