<?php use function App\Core\e; $section = 'bildirimler'; ?>
<div class="panel zpanel zpanel-app">
    <?php require BASE_PATH . '/app/Views/zpanel/_sidebar.php'; ?>
    <section class="panel-body zpanel-main">
        <div class="zpanel-head"><div><p class="eyebrow">ZPanel</p><h1>Bildirimler</h1><p class="muted">Tum kullanicilara, role veya belirli kullaniciya sistem bildirimi gonder.</p></div></div>
        <section class="zpanel-card"><form class="zpanel-form grid" data-zpanel-form action="/api/zpanel/notifications/send" method="post">
            <input type="hidden" name="_csrf" value="<?= e($csrfToken ?? '') ?>">
            <label>Hedef<select name="target_type"><option value="all">Tum kullanicilar</option><option value="role">Belirli role</option><option value="user">Belirli kullanici</option></select></label>
            <label>Role<select name="role"><option value="user">user</option><option value="creator">creator</option><option value="moderator">moderator</option><option value="admin">admin</option></select></label>
            <label>Kullanici ID<input name="user_id" type="number" min="1"></label>
            <label>URL<input name="url" placeholder="/studyo"></label>
            <label class="wide">Baslik<input name="title" required></label>
            <label class="wide">Mesaj<textarea name="body" required></textarea></label>
            <button class="pill primary" type="submit">Gonder</button>
        </form></section>
        <section class="zpanel-card"><div class="zpanel-card-head"><h2>Son bildirimler</h2></div><div class="table-scroll"><table class="zpanel-table compact"><thead><tr><th>Kullanici</th><th>Baslik</th><th>Mesaj</th><th>Tarih</th></tr></thead><tbody><?php foreach (($recent ?? []) as $row): ?><tr><td><?= e($row['username'] ?? '-') ?></td><td><?= e($row['title'] ?? '') ?></td><td><?= e($row['body'] ?? '') ?></td><td><?= e($row['created_at'] ?? '') ?></td></tr><?php endforeach; ?><?php if (empty($recent)): ?><tr><td colspan="4">Bildirim yok.</td></tr><?php endif; ?></tbody></table></div></section>
    </section>
</div>
