<?php $activeNav = 'dashboard'; ?>
<?= $this->extend('organizer/layouts/main') ?>
<?= $this->section('content') ?>

<h1 class="h4 mb-3">My Events</h1>

<?php if (empty($events)): ?>
    <div class="card">
        <div class="card-body text-center py-5">
            <i class="bi bi-calendar-x text-muted" style="font-size: 2rem;"></i>
            <p class="text-muted mt-2 mb-0">No events have been assigned to you yet. Contact the hotel if you're expecting to see one here.</p>
        </div>
    </div>
<?php else: ?>
    <div class="row g-3">
        <?php foreach ($events as $event): ?>
            <div class="col-md-6 col-lg-4">
                <a href="<?= site_url('organizer/events/' . $event->id) ?>" class="text-decoration-none text-body">
                    <div class="card h-100">
                        <div class="card-body">
                            <div class="d-flex justify-content-between align-items-start mb-2">
                                <h2 class="h6 mb-0"><?= esc($event->event_name) ?></h2>
                                <span class="badge bg-<?= esc($lookups->eventStatuses[$event->status]['badge'] ?? 'secondary') ?>"><?= esc($lookups->eventStatuses[$event->status]['label'] ?? $event->status) ?></span>
                            </div>
                            <p class="text-muted small mb-1"><i class="bi bi-calendar3 me-1"></i><?= esc(date('d M Y', strtotime($event->event_date))) ?></p>
                            <?php if ($event->venue_space): ?>
                                <p class="text-muted small mb-0"><i class="bi bi-geo-alt me-1"></i><?= esc($event->venue_space) ?></p>
                            <?php endif; ?>
                        </div>
                    </div>
                </a>
            </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>

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