<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5">
    <title>{{ platform_name }}</title>
    <style>
        :root {
            --primary: #2563eb;
            --primary-hover: #1d4ed8;
            --gray-50: #f9fafb;
            --gray-100: #f3f4f6;
            --gray-200: #e5e7eb;
            --gray-500: #6b7280;
            --gray-700: #374151;
            --gray-900: #111827;
        }

        * { box-sizing: border-box; margin: 0; padding: 0; }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* 顶部导航 */
        .navbar {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            padding: 16px 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        }

        .navbar-brand {
            color: white;
            font-size: 20px;
            font-weight: 700;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .navbar-user {
            color: white;
            display: flex;
            align-items: center;
            gap: 16px;
            font-size: 14px;
        }

        .btn-logout {
            background: rgba(255, 255, 255, 0.15);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.3);
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            text-decoration: none;
            transition: background 0.2s;
        }

        .btn-logout:hover {
            background: rgba(255, 255, 255, 0.25);
        }

        /* 主体 */
        .container {
            max-width: 960px;
            margin: 0 auto;
            padding: 40px 24px;
            flex: 1;
        }

        .page-header {
            text-align: center;
            margin-bottom: 40px;
        }

        .page-header h1 {
            color: white;
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 8px;
        }

        .page-header p {
            color: rgba(255, 255, 255, 0.8);
            font-size: 16px;
        }

        /* 模块卡片网格 */
        .module-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 24px;
        }

        .module-card {
            background: white;
            border-radius: 16px;
            padding: 32px 24px;
            text-align: center;
            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s, box-shadow 0.2s;
            cursor: pointer;
            text-decoration: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 16px;
        }

        .module-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
        }

        .module-icon {
            font-size: 48px;
            line-height: 1;
        }

        .module-name {
            font-size: 18px;
            font-weight: 700;
            color: var(--gray-900);
        }

        .module-desc {
            font-size: 14px;
            color: var(--gray-500);
            line-height: 1.5;
        }

        .module-enter {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: var(--primary);
            color: white;
            padding: 10px 24px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            margin-top: 8px;
            transition: background 0.2s;
        }

        .module-card:hover .module-enter {
            background: var(--primary-hover);
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: rgba(255, 255, 255, 0.8);
        }

        .empty-state .icon {
            font-size: 64px;
            margin-bottom: 16px;
        }

        .empty-state p {
            font-size: 16px;
        }

        /* 页脚 */
        .footer {
            text-align: center;
            padding: 20px;
            color: rgba(255, 255, 255, 0.6);
            font-size: 12px;
        }

        /* ===== 移动端响应式 ===== */
        @media screen and (max-width: 1024px) {
            .module-grid { grid-template-columns: repeat(2, 1fr); }
        }

        @media screen and (max-width: 768px) {
            .container { padding: 24px 16px; }
            .module-grid { grid-template-columns: 1fr; }
            .page-header h1 { font-size: 22px; }
            .module-card { padding: 24px 20px; }
            .navbar { padding: 12px 16px; }
            .navbar-brand { font-size: 16px; }
            .btn-logout { min-height: 44px; font-size: 16px; }
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="navbar">
        <a href="/" class="navbar-brand">🛠️ {{ platform_name }}</a>
        <div class="navbar-user">
            <span>{{ user.username }}（{{ '管理员' if user.role == 'admin' else '用户' }}）</span>
            <button class="btn-logout" onclick="handleLogout()">🚪 退出</button>
        </div>
    </div>

    <!-- 主体 -->
    <div class="container">
        <div class="page-header">
            <h1>🛠️ {{ platform_name }}</h1>
            <p>选择要使用的功能模块</p>
        </div>

        {% if modules %}
        <div class="module-grid">
            {% for m in modules %}
            <a href="{{ m.url }}" class="module-card">
                <div class="module-icon">{{ m.icon }}</div>
                <div class="module-name">{{ m.name }}</div>
                <div class="module-desc">{{ m.description }}</div>
                <div class="module-enter">进入 →</div>
            </a>
            {% endfor %}
        </div>
        {% else %}
        <div class="empty-state">
            <div class="icon">📭</div>
            <p>暂无可用模块</p>
        </div>
        {% endif %}
    </div>

    <div class="footer">
        {{ platform_name }} · 运行维护工具集
    </div>

    <script>
        async function handleLogout() {
            try {
                await fetch('/logout', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    credentials: 'include'
                });
            } catch (e) {}
            window.location.href = '/login';
        }
    </script>
</body>
</html>
