<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="d-flex justify-content-between align-items-start mb-3">
    <div>
        <p class="text-muted mb-0">Rooms booked together for one organization or party — a conference, a wedding, any group arriving as a block.</p>
    </div>
    <a href="<?= site_url('group-bookings/new') ?>" class="btn btn-primary"><i class="bi bi-people-fill me-1"></i>New Group Booking</a>
</div>

<div class="card shadow-sm">
    <div class="list-group list-group-flush">
        <?php if (empty($groups)): ?>
            <div class="list-group-item text-center text-muted py-5">No group bookings yet.</div>
        <?php endif; ?>
        <?php foreach ($groups as $g): ?>
            <a href="<?= site_url('group-bookings/' . $g->id) ?>" class="list-group-item list-group-item-action">
                <div class="d-flex justify-content-between align-items-center gap-3">
                    <div>
                        <span class="fw-semibold"><?= esc($g->group_name) ?></span>
                        <?php if ($g->company_name): ?><span class="text-muted small ms-2"><i class="bi bi-briefcase me-1"></i><?= esc($g->company_name) ?></span>
                        <?php elseif ($g->organizer_name): ?><span class="text-muted small ms-2"><?= esc($g->organizer_name) ?></span>
                        <?php endif; ?>
                    </div>
                    <div class="d-flex align-items-center gap-3">
                        <span class="text-muted small"><?= esc(date('d M Y', strtotime($g->check_in_date))) ?> &rarr; <?= esc(date('d M Y', strtotime($g->check_out_date))) ?></span>
                        <span class="badge bg-light text-dark border"><?= $g->roomCount ?> room<?= $g->roomCount === 1 ? '' : 's' ?></span>
                        <span class="badge bg-<?= $g->status === 'cancelled' ? 'danger' : 'success' ?>"><?= esc(ucfirst($g->status)) ?></span>
                    </div>
                </div>
            </a>
        <?php endforeach; ?>
    </div>
</div>

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