<?php $title = 'Event Attendees'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><i class="fas fa-users mr-2"></i>Attendees: <?= htmlspecialchars($event->title ?? '') ?></h1>
    <a href="<?= $baseUrl ?>/events/<?= $event->id ?? 0 ?>" class="glass-btn"><i class="fas fa-arrow-left mr-1"></i>Back to Event</a>
</div>
<div class="glass-table">
    <table class="table">
        <thead><tr><th>Name</th><th>Email</th><th>Status</th><th>Registered</th><th>Action</th></tr></thead>
        <tbody>
            <?php if (!empty($attendees)): ?>
                <?php foreach ($attendees as $att): ?>
                <tr>
                    <td><?= htmlspecialchars($att->user_name ?? 'Unknown') ?></td>
                    <td><?= htmlspecialchars($att->user_email ?? '') ?></td>
                    <td><span class="glass-badge"><?= htmlspecialchars($att->status) ?></span></td>
                    <td><?= date('M d, Y H:i', strtotime($att->registered_at)) ?></td>
                    <td>
                        <form method="POST" action="<?= $baseUrl ?>/attendance/<?= $event->id ?>/mark" style="display:inline;">
                            <input type="hidden" name="user_id" value="<?= $att->user_id ?>">
                            <select name="status" class="form-control form-control-sm glass-input" style="width: auto; display: inline-block;" onchange="this.form.submit()">
                                <option value="registered" <?= $att->status === 'registered' ? 'selected' : '' ?>>Registered</option>
                                <option value="attended" <?= $att->status === 'attended' ? 'selected' : '' ?>>Attended</option>
                                <option value="absent" <?= $att->status === 'absent' ? 'selected' : '' ?>>Absent</option>
                                <option value="cancelled" <?= $att->status === 'cancelled' ? 'selected' : '' ?>>Cancelled</option>
                            </select>
                        </form>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr><td colspan="5" class="text-center" style="color: rgba(255,255,255,0.5);">No attendees registered</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
