<?php $title = 'Inbox - 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"><i class="fas fa-inbox mr-2"></i>Inbox</h1>
    <a href="<?= $baseUrl ?>/messages/compose" class="glass-btn glass-btn-primary"><i class="fas fa-plus mr-1"></i>Compose</a>
</div>
<div class="glass-card p-0">
    <div class="list-group list-group-flush">
        <?php if (!empty($messages)): ?>
            <?php foreach ($messages as $msg): ?>
            <a href="<?= $baseUrl ?>/messages/<?= $msg->id ?>" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" style="background: transparent; color: white; border-color: rgba(255,255,255,0.05); <?= !$msg->is_read ? 'border-left: 3px solid #4e73df;' : '' ?>">
                <div class="flex-grow-1">
                    <div class="d-flex justify-content-between">
                        <strong><?= $msg->is_read ? '' : '<i class="fas fa-circle text-primary mr-1" style="font-size: 0.5rem;"></i>' ?><?= htmlspecialchars($msg->subject) ?></strong>
                        <small style="color: rgba(255,255,255,0.4);"><?= date('M d, Y H:i', strtotime($msg->created_at)) ?></small>
                    </div>
                    <small style="color: rgba(255,255,255,0.5);">From: <?= htmlspecialchars($msg->sender_name ?? 'System') ?></small>
                </div>
            </a>
            <?php endforeach; ?>
        <?php else: ?>
            <div class="empty-state"><i class="fas fa-envelope"></i><p>No messages in inbox</p></div>
        <?php endif; ?>
    </div>
</div>
