<div class="page-head">
    <div><h1>仪表盘</h1><div class="desc">网站数据概览与快捷操作</div></div>
    <a class="btn-primary" href="<?php echo site_url('admin/products/create'); ?>"><?php echo admin_icon('plus', 18); ?> 新增产品</a>
</div>

<div class="stat-row">
    <div class="stat-box c1"><span class="stat-ic"><?php echo admin_icon('snowflake', 22); ?></span><b><?php echo e($counts['products']); ?></b><span>产品数量</span></div>
    <div class="stat-box c2"><span class="stat-ic"><?php echo admin_icon('folders', 22); ?></span><b><?php echo e($counts['categories']); ?></b><span>分类数量</span></div>
    <div class="stat-box c3"><span class="stat-ic"><?php echo admin_icon('newspaper', 22); ?></span><b><?php echo e($counts['news']); ?></b><span>新闻数量</span></div>
    <div class="stat-box c4"><span class="stat-ic"><?php echo admin_icon('images', 22); ?></span><b><?php echo e($counts['banners']); ?></b><span>轮播数量</span></div>
</div>

<div class="admin-card">
    <h3 style="margin:0 0 14px;display:flex;align-items:center;gap:8px"><?php echo admin_icon('newspaper', 18); ?> 最近新闻</h3>
    <?php if (empty($news)): ?><p class="muted">暂无新闻</p><?php endif; ?>
    <?php if (!empty($news)): ?>
    <table class="admin-table">
        <tr><th>标题</th><th>发布日期</th><th>操作</th></tr>
        <?php foreach ($news as $n): ?>
            <tr>
                <td><?php echo e($n['title']); ?></td>
                <td class="muted"><?php echo e(format_date($n['published_at'])); ?></td>
                <td><a class="btn-soft btn-sm" href="<?php echo site_url('admin/news/edit/' . $n['id']); ?>"><?php echo admin_icon('pencil', 14); ?> 编辑</a></td>
            </tr>
        <?php endforeach; ?>
    </table>
    <?php endif; ?>
</div>

<div class="admin-card" style="margin-top:22px">
    <h3 style="margin:0 0 16px;display:flex;align-items:center;gap:8px"><?php echo admin_icon('dashboard', 18); ?> 快捷入口</h3>
    <div class="quick-actions">
        <?php if (admin_role() === 'super_admin'): ?>
        <a class="qa-card" href="<?php echo site_url('admin/users'); ?>"><span class="qa-ico"><?php echo admin_icon('users', 22); ?></span><span class="qa-t">用户管理</span><span class="qa-d">账号与权限分配</span></a>
        <?php endif; ?>
        <a class="qa-card" href="<?php echo site_url('admin/theme'); ?>"><span class="qa-ico"><?php echo admin_icon('palette', 22); ?></span><span class="qa-t">风格设置</span><span class="qa-d">主题配色与外观</span></a>
        <a class="qa-card" href="<?php echo site_url('admin/settings'); ?>"><span class="qa-ico"><?php echo admin_icon('settings', 22); ?></span><span class="qa-t">站点设置</span><span class="qa-d">基础信息与 SEO</span></a>
        <a class="qa-card" href="<?php echo site_url('admin/banners'); ?>"><span class="qa-ico"><?php echo admin_icon('images', 22); ?></span><span class="qa-t">轮播管理</span><span class="qa-d">首页横幅图</span></a>
        <a class="qa-card" href="<?php echo site_url('admin/password'); ?>"><span class="qa-ico"><?php echo admin_icon('key', 22); ?></span><span class="qa-t">修改密码</span><span class="qa-d">账户安全</span></a>
        <a class="qa-card" href="<?php echo site_url(); ?>" target="_blank"><span class="qa-ico"><?php echo admin_icon('globe', 22); ?></span><span class="qa-t">查看前台</span><span class="qa-d">在新窗口打开</span></a>
    </div>
</div>
