<?php $title = htmlspecialchars($event->title) . ' - Ghana Anaesthesiologists Society'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><?= htmlspecialchars($event->title) ?></h1>
    <div>
        <?php if (isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'admin'): ?>
        <a href="<?= $baseUrl ?>/events/<?= $event->id ?>/edit" class="glass-btn mr-2"><i class="fas fa-edit"></i></a>
        <a href="<?= $baseUrl ?>/events/<?= $event->id ?>/attendees" class="glass-btn mr-2"><i class="fas fa-users"></i> Attendees</a>
        <?php endif; ?>
        <?php if ($event->status === 'upcoming' || $event->status === 'ongoing'): ?>
            <?php if ($isRegistered): ?>
                <form method="POST" action="<?= $baseUrl ?>/events/<?= $event->id ?>/unregister" style="display:inline;">
                    <button type="submit" class="glass-btn glass-btn-danger">Cancel Registration</button>
                </form>
            <?php else: ?>
                <form method="POST" action="<?= $baseUrl ?>/events/<?= $event->id ?>/register" style="display:inline;">
                    <button type="submit" class="glass-btn glass-btn-primary">Register Now</button>
                </form>
            <?php endif; ?>
        <?php endif; ?>
    </div>
</div>
<div class="row">
    <div class="col-lg-8">
        <div class="glass-card mb-4">
            <h5 class="font-weight-bold mb-3">Description</h5>
            <p style="color: rgba(255,255,255,0.7);"><?= nl2br(htmlspecialchars($event->description ?? 'No description')) ?></p>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="glass-card">
            <h5 class="font-weight-bold mb-3">Event Details</h5>
            <div class="mb-2"><i class="fas fa-calendar-day mr-2 text-primary"></i> <strong>Date:</strong> <?= date('F d, Y', strtotime($event->start_datetime)) ?></div>
            <div class="mb-2"><i class="fas fa-clock mr-2 text-primary"></i> <strong>Time:</strong> <?= date('H:i', strtotime($event->start_datetime)) ?></div>
            <?php if ($event->venue): ?><div class="mb-2"><i class="fas fa-map-marker-alt mr-2 text-primary"></i> <strong>Venue:</strong> <?= htmlspecialchars($event->venue) ?></div><?php endif; ?>
            <div class="mb-2"><i class="fas fa-tag mr-2 text-primary"></i> <strong>Type:</strong> <?= htmlspecialchars($event->event_type) ?></div>
            <div class="mb-2"><i class="fas fa-users mr-2 text-primary"></i> <strong>Attendees:</strong> <?= $attendeeCount ?><?= $event->max_attendees ? ' / ' . $event->max_attendees : '' ?></div>
            <?php if ($event->fee > 0): ?><div class="mb-2"><i class="fas fa-money-bill mr-2 text-primary"></i> <strong>Fee:</strong> GHS <?= number_format($event->fee, 2) ?></div><?php endif; ?>
            <span class="glass-badge mt-2 d-inline-block"><?= htmlspecialchars($event->status) ?></span>
        </div>
    </div>
</div>
