<div class="page-head">
    <div><h1>新闻管理</h1><div class="desc">新闻动态与案例</div></div>
    <a class="btn-primary" href="<?php echo site_url('admin/news/create'); ?>">+ 写新闻</a>
</div>
<div class="admin-card">
    <table class="admin-table">
        <tr><th>封面</th><th>标题</th><th>模式</th><th>作者</th><th>日期</th><th>状态</th><th>操作</th></tr>
        <?php foreach ($news as $n): ?>
            <?php $nm = empty($n['mode']) ? 'fixed' : $n['mode']; ?>
            <tr>
                <td><div class="thum" style="background:<?php echo gradient($n['id']); ?>">📰</div></td>
                <td><b><?php echo e($n['title']); ?></b></td>
                <td><span class="mode-badge <?php echo $nm === 'builder' ? 'builder' : 'fixed'; ?>"><?php echo $nm === 'builder' ? '可视化' : '固定'; ?></span></td>
                <td class="muted"><?php echo e($n['author']); ?></td>
                <td class="muted"><?php echo e(format_date($n['published_at'])); ?></td>
                <td><?php echo ($n['status'] ?? 1) ? '<span class="tag-mini">已发布</span>' : '<span class="muted">草稿</span>'; ?></td>
                <td>
                    <div class="row-actions">
                        <a class="btn-soft btn-sm" href="<?php echo site_url('admin/news/edit/' . $n['id']); ?>">编辑</a>
                        <form class="del-form" method="post" action="<?php echo site_url('admin/news/delete/' . $n['id']); ?>"><?php echo csrf_field(); ?><button class="btn-danger btn-sm" type="submit">删除</button></form>
                    </div>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
</div>
<style>
.mode-badge{display:inline-block;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:600}
.mode-badge.fixed{background:#f1f5f9;color:#475569}
.mode-badge.builder{background:#ede9fe;color:#6d28d9}
</style>
