<?php
/**
 * Shared between the staff event page and the organizer portal — layout
 * is parameterized ($layout) so an organizer viewing their own
 * registrant's answers gets the light organizer chrome, not the staff
 * sidebar (which assumes a staff session/role that doesn't exist for an
 * organizer session).
 */
?>
<?= $this->extend($layout ?? 'layouts/main') ?>
<?= $this->section('content') ?>

<div class="d-flex justify-content-between align-items-start mb-3">
    <div>
        <h1 class="h3 mb-1"><?= esc($registration->full_name) ?></h1>
        <p class="text-muted mb-0"><?= esc($event->event_name) ?> · <?= esc($registration->phone) ?><?= $registration->email ? ' · ' . esc($registration->email) : '' ?></p>
    </div>
    <a href="<?= site_url($baseUrl . '/' . $event->id) ?>" class="btn btn-outline-secondary btn-sm">Back to Event</a>
</div>

<div class="card shadow-sm">
    <div class="card-header">Registration Answers</div>
    <div class="card-body">
        <?php if (empty($fields)): ?>
            <p class="text-muted small mb-0">This event has no custom registration questions.</p>
        <?php else: ?>
            <?php foreach ($fields as $field): ?>
                <?php $answer = $values[$field->id] ?? null; ?>
                <div class="mb-3">
                    <div class="text-muted small"><?= esc($field->label) ?></div>
                    <div class="fw-semibold">
                        <?php if ($answer === null || $answer === ''): ?>
                            <span class="text-muted fw-normal">— no answer —</span>
                        <?php elseif (is_array($answer)): ?>
                            <?= esc(implode(', ', $answer)) ?>
                        <?php else: ?>
                            <?= esc($answer) ?>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endforeach; ?>
        <?php endif; ?>
    </div>
</div>

<?= $this->endSection() ?>
