<?php
/**
 * HuSNS - 一款免费开源的社交平台
 * 
 * @author  HYR
 * @QQ      281900864
 * @website https://huyourui.com
 * @license MIT
 * @声明    严禁用于违法违规用途
 */
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($title) ? $title . ' - ' : ''; ?>后台管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" href="<?php echo $this->asset('css/admin.css'); ?>">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="admin-wrapper">
        <aside class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <h2 class="sidebar-title">后台管理</h2>
                <button class="sidebar-toggle" id="sidebarToggle" aria-label="折叠侧边栏">
                    <span class="toggle-icon">☰</span>
                </button>
            </div>
            <nav class="sidebar-nav" id="sidebarNav">
                <a href="<?php echo $this->url('admin'); ?>" class="nav-item <?php echo !isset($_GET['action']) ? 'active' : ''; ?>">
                    <span class="nav-icon">📊</span>
                    <span class="nav-text">仪表盘</span>
                </a>
                
                <!-- 内容管理 -->
                <div class="nav-section" data-section="content">
                    <div class="nav-section-title">
                        <span>内容管理</span>
                        <span class="section-arrow">▶</span>
                    </div>
                    <div class="nav-section-content">
                        <a href="<?php echo $this->url('admin/users'); ?>" class="nav-item">
                            <span class="nav-icon">👥</span>
                            <span class="nav-text">用户管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/posts'); ?>" class="nav-item">
                            <span class="nav-icon">📝</span>
                            <span class="nav-text">动态管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/comments'); ?>" class="nav-item">
                            <span class="nav-icon">💬</span>
                            <span class="nav-text">评论管理</span>
                        </a>
                        <a href="<?php echo $this->url('topic'); ?>" class="nav-item">
                            <span class="nav-icon">🏷️</span>
                            <span class="nav-text">话题管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/circles'); ?>" class="nav-item">
                            <span class="nav-icon">🔄</span>
                            <span class="nav-text">圈子管理</span>
                        </a>
                    </div>
                </div>
                
                <!-- 运营管理 -->
                <div class="nav-section" data-section="operation">
                    <div class="nav-section-title">
                        <span>运营管理</span>
                        <span class="section-arrow">▶</span>
                    </div>
                    <div class="nav-section-content">
                        <a href="<?php echo $this->url('admin/reports'); ?>" class="nav-item">
                            <span class="nav-icon">🚨</span>
                            <span class="nav-text">举报管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/filter'); ?>" class="nav-item">
                            <span class="nav-icon">🔤</span>
                            <span class="nav-text">敏感词过滤</span>
                        </a>
                        <a href="<?php echo $this->url('point'); ?>" class="nav-item">
                            <span class="nav-icon">⭐</span>
                            <span class="nav-text"><?php echo $this->escape(Setting::getPointName()); ?>规则</span>
                        </a>
                        <a href="<?php echo $this->url('pointSignin'); ?>" class="nav-item">
                            <span class="nav-icon">📅</span>
                            <span class="nav-text">签到管理</span>
                        </a>
                        <a href="<?php echo $this->url('invite'); ?>" class="nav-item">
                            <span class="nav-icon">🎟️</span>
                            <span class="nav-text">邀请码管理</span>
                        </a>
                        <a href="<?php echo $this->url('announcement'); ?>" class="nav-item">
                            <span class="nav-icon">📢</span>
                            <span class="nav-text">公告管理</span>
                        </a>
                        <a href="<?php echo $this->url('link'); ?>" class="nav-item">
                            <span class="nav-icon">🔗</span>
                            <span class="nav-text">友情链接</span>
                        </a>
                    </div>
                </div>
                
                <!-- 系统管理 -->
                <div class="nav-section" data-section="system">
                    <div class="nav-section-title">
                        <span>系统管理</span>
                        <span class="section-arrow">▶</span>
                    </div>
                    <div class="nav-section-content">
                        <a href="<?php echo $this->url('admin/statistics'); ?>" class="nav-item">
                            <span class="nav-icon">📈</span>
                            <span class="nav-text">数据统计</span>
                        </a>
                        <a href="<?php echo $this->url('admin/attachments'); ?>" class="nav-item">
                            <span class="nav-icon">📁</span>
                            <span class="nav-text">附件管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/clearCache'); ?>" class="nav-item">
                            <span class="nav-icon">🗑️</span>
                            <span class="nav-text">清理缓存</span>
                        </a>
                        <a href="<?php echo $this->url('admin/backup'); ?>" class="nav-item">
                            <span class="nav-icon">📦</span>
                            <span class="nav-text">数据备份</span>
                        </a>
                        <a href="<?php echo $this->url('admin/roles'); ?>" class="nav-item">
                            <span class="nav-icon">🎭</span>
                            <span class="nav-text">角色管理</span>
                        </a>
                        <a href="<?php echo $this->url('admin/admin_users'); ?>" class="nav-item">
                            <span class="nav-icon">🔐</span>
                            <span class="nav-text">管理员管理</span>
                        </a>
                        <a href="<?php echo $this->url('plugin'); ?>" class="nav-item">
                            <span class="nav-icon">🔌</span>
                            <span class="nav-text">插件管理</span>
                        </a>
                        <a href="<?php echo $this->url('theme'); ?>" class="nav-item">
                            <span class="nav-icon">🎨</span>
                            <span class="nav-text">主题管理</span>
                        </a>
                        <a href="<?php echo $this->url('upgrade'); ?>" class="nav-item">
                            <span class="nav-icon">🔄</span>
                            <span class="nav-text">系统更新</span>
                        </a>
                        <a href="<?php echo $this->url('admin/settings'); ?>" class="nav-item">
                            <span class="nav-icon">⚙️</span>
                            <span class="nav-text">系统设置</span>
                        </a>
                    </div>
                </div>
                
                <!-- 返回前台 -->
                <a href="<?php echo $this->url(); ?>" class="nav-item">
                    <span class="nav-icon">🏠</span>
                    <span class="nav-text">返回前台</span>
                </a>
            </nav>
        </aside>

        <main class="admin-main">
            <header class="admin-header">
                <span>欢迎，<?php echo $_SESSION['username'] ?? ''; ?></span>
                <a href="<?php echo $this->url('user/logout'); ?>">退出</a>
            </header>

            <div class="admin-content">
                <?php if ($this->hasFlash('success')): ?>
                <div class="alert alert-success"><?php echo $this->flash('success'); ?></div>
                <?php endif; ?>
                
                <?php if ($this->hasFlash('error')): ?>
                <div class="alert alert-error"><?php echo $this->flash('error'); ?></div>
                <?php endif; ?>

                <?php echo $content; ?>
            </div>
            
            <footer class="admin-footer">
                &copy; <?php echo date('Y'); ?> <?php echo $this->escape(Setting::getSiteName()); ?> | Powered by <a href="https://huyourui.com" target="_blank" rel="noopener">HuSNS</a>
            </footer>
        </main>
    </div>

    <script src="<?php echo $this->asset('js/admin.js'); ?>"></script>
</body>
</html>
