<?php $pageTitle = t('notifications'); ?>
<div class="page-header">
    <div class="page-header-left">
        <a href="/dashboard" class="btn btn-ghost btn-sm">
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
            <?= t('dashboard') ?>
        </a>
        <h1 class="page-title"><?= t('notifications') ?></h1>
    </div>
    <form method="POST">
        <?= Helper::csrf() ?>
        <button type="submit" class="btn btn-ghost btn-sm"><?= t('mark_all_read') ?></button>
    </form>
</div>

<div class="card">
    <div class="card-body p-0">
        <?php if (empty($notifications)): ?>
        <div class="empty-state-small"><?= t('no_notifications') ?></div>
        <?php else: ?>
        <div class="notif-full-list">
            <?php foreach ($notifications as $n): ?>
            <div class="notif-full-item <?= $n['is_read'] ? '' : 'unread' ?>">
                <div class="notif-indicator"></div>
                <div class="notif-body">
                    <div class="notif-title"><?= Helper::e($n['title']) ?></div>
                    <div class="notif-message"><?= Helper::e($n['message']) ?></div>
                    <div class="notif-time"><?= Helper::timeAgo($n['created_at']) ?></div>
                </div>
                <?php if ($n['related_type'] === 'task' && $n['related_id']): ?>
                <a href="/task/<?= $n['related_id'] ?>" class="btn btn-ghost btn-xs"><?= t('open_btn') ?></a>
                <?php endif; ?>
            </div>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
</div>
