<?php $pageTitle = 'Announcements'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <p class="text-secondary mb-0">System announcements</p>
    <a href="<?= base_url('admin/announcement-create') ?>" class="btn-cix btn-cix-accent btn-cix-sm"><i class="fas fa-plus"></i> New Announcement</a>
</div>
<div class="card-cix">
    <?php if (empty($announcements)): ?>
        <div class="empty-state"><i class="fas fa-bullhorn"></i><h5>No Announcements</h5></div>
    <?php else: ?>
        <?php foreach ($announcements as $ann): ?>
        <div style="padding:1rem;border-bottom:1px solid var(--border);">
            <div class="d-flex align-items-center gap-2 mb-1">
                <?php if ($ann['is_pinned']): ?><span class="badge-cix badge-submitted" style="font-size:0.65rem;">PINNED</span><?php endif; ?>
                <h5 class="mb-0"><?= e($ann['title']) ?></h5>
            </div>
            <p class="text-secondary mb-1"><?= e(substr($ann['content'], 0, 200)) ?></p>
            <small class="text-secondary">By <?= e(($ann['first_name'] ?? 'System') . ' ' . ($ann['last_name'] ?? '')) ?> | <?= time_elapsed($ann['created_at']) ?></small>
        </div>
        <?php endforeach; ?>
    <?php endif; ?>
</div>
