<?php use function App\Core\e; $section = 'yorumlar'; ?>
<div class="panel zpanel zpanel-app">
    <?php require BASE_PATH . '/app/Views/zpanel/_sidebar.php'; ?>
    <section class="panel-body zpanel-main" data-zpanel-page>
        <div class="zpanel-head"><div><p class="eyebrow">ZPanel</p><h1>Yorum Yonetimi</h1><p class="muted">Tum yorumlari content type, status ve risk skoruna gore yonet.</p></div></div>
        <form class="zpanel-filters" method="get"><input name="q" value="<?= e($_GET['q'] ?? '') ?>" placeholder="Yorum veya kullanici ara"><select name="content_type"><option value="">Tum icerikler</option><?php foreach (['mod','music','community'] as $type): ?><option value="<?= e($type) ?>" <?= ($_GET['content_type'] ?? '') === $type ? 'selected' : '' ?>><?= e($type) ?></option><?php endforeach; ?></select><select name="status"><option value="">Tum status</option><?php foreach (['published','pending_review','blocked','visible','hidden','pending','deleted'] as $status): ?><option value="<?= e($status) ?>" <?= ($_GET['status'] ?? '') === $status ? 'selected' : '' ?>><?= e($status) ?></option><?php endforeach; ?></select><button class="pill primary">Filtrele</button></form>
        <section class="zpanel-card"><div class="table-scroll"><table class="zpanel-table">
            <thead><tr><th>ID</th><th>Kullanici</th><th>Tip</th><th>Yorum</th><th>Status</th><th>Risk</th><th>Tarih</th><th>Aksiyon</th></tr></thead><tbody>
            <?php foreach (($comments ?? []) as $comment): ?><tr><td><?= e($comment['id'] ?? '') ?></td><td><?= e($comment['display_name'] ?? $comment['username'] ?? '-') ?></td><td><?= e($comment['content_type'] ?? '-') ?> #<?= e($comment['content_id'] ?? '') ?></td><td><?= e($comment['content'] ?? '') ?></td><td><span class="status-pill"><?= e($comment['status'] ?? '') ?></span></td><td><?= e((string) ($comment['risk_score'] ?? 0)) ?></td><td><?= e($comment['created_at'] ?? '') ?></td><td class="action-row"><?php foreach ([['/api/zpanel/comments/approve','Onayla'],['/api/zpanel/comments/block','Block'],['/api/zpanel/comments/delete','Sil']] as $action): ?><form data-zpanel-form action="<?= e($action[0]) ?>" method="post" data-confirm="<?= e($action[1]) ?>?"><input type="hidden" name="_csrf" value="<?= e($csrfToken ?? '') ?>"><input type="hidden" name="id" value="<?= e($comment['id'] ?? '') ?>"><button type="submit"><?= e($action[1]) ?></button></form><?php endforeach; ?></td></tr><?php endforeach; ?>
            <?php if (empty($comments)): ?><tr><td colspan="8">Yorum yok.</td></tr><?php endif; ?>
            </tbody></table></div></section>
    </section>
</div>
