<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>不眠之夜 - Minecraft服务器</title>
    <link rel="shortcut icon" href="/favicon.png">
    
    <!-- 核心样式 -->
    <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap" rel="stylesheet">
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
    
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

    <style>
        @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
        :root {
            --primary-color: #FF00FF;
        }
        body {
            background-image: url('/static/img/IMG_6421.PNG');
            background-size: cover;
            background-attachment: fixed;
            min-height: 100vh;
            position: relative;
            overflow: hidden; /* 禁止滚动 */
        }

        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: inherit;
            filter: blur(3px); /* 轻微模糊效果 */
            z-index: -1;
        }
        #main-nav {
            position: fixed;
            top: 0;
            width: 100%;
            height: 70px;
            background: #fff;
            box-shadow: 0 2px 15px rgba(0,0,0,0.8);
            z-index: 1000;
        }

        .nav-container {
            position: relative;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
            height: 100%;
        }

        .nav-brand {
            font-size: 1.8rem;
            color: var(--primary-color) !important;
            font-weight: bold;
            line-height: 70px;
        }

        .auth-btn {
            padding: 8px 25px !important;
            border-radius: 25px !important;
            transition: all 0.3s !important;
        }
        .btn-login {
            background: var(--primary-color) !important;
            border-color: var(--primary-color) !important;
            color: white !important;
        }
        .btn-register {
            background: #f8f9fa !important;
            border-color: var(--primary-color) !important;
            color: var(--primary-color) !important;
        }
        .btn {
            transition: transform 0.3s; /* 平滑过渡 */
        }

        .btn:hover {
            transform: scale(1.05); /* 鼠标悬停时放大 */
        }
        .user-avatar {
            width: 40px;
            height: 40px;
            object-fit: cover;
            border: 2px solid var(--primary-color);
            transition: transform 0.3s;
        }
        .user-avatar:hover {
            transform: scale(1.1);
        }

        /* 新增下拉菜单样式 */
        .dropdown-menu {
            min-width: 400px;
        }
        .dropdown-item {
            padding: 0.5rem 1.5rem;
        }
        .dropdown-item i {
            width: 1.2em;
            margin-right: 0.8rem;
        }
    </style>
</head>
    
<body>
<nav id="main-nav">
    <div class="nav-container d-flex justify-content-between align-items-center">
        <a href="https://qm.qq.com/q/xZca4kNJxm" class="nav-brand">
            <img src="/static/img/logo.png" alt="不眠之夜" style="height: 40px;">
        </a>
        
        <div class="d-flex gap-3 align-items-center">
            <div id="serverStatus" class="badge"></div>
            
            <!-- 时间显示 -->
            <div id="navTime" class="nav-time"></div>
            
            <!-- 用户菜单 -->
                % if user:
                <div class="dropdown">
                    <a class="d-flex align-items-center text-decoration-none" 
                       data-bs-toggle="dropdown">
                        <img src="/static/{{ user.avatar or 'avatars/default_avatar.png' }}" 
                             class="nav-avatar rounded-circle"
                             onerror="this.onerror=null;this.src='/static/avatars/default_avatar.png'">
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end shadow">
                        <li class="px-3 py-2">
                            <div class="d-flex justify-content-between align-items-center">
                                <h6 class="mb-0">{{! user.display_name }}</h6>
                                <span class="badge bg-primary">Lv.{{ user.level }}</span>
                            </div>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <a class="dropdown-item" href="/profile">
                                <i class="bi bi-person me-2"></i>个人中心
                            </a>
                        </li>
                        <li>
                            <a class="dropdown-item" href="#signatureModal" data-bs-toggle="modal">
                                <i class="bi bi-pencil me-2"></i>编辑签名
                            </a>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <a class="dropdown-item text-danger" href="javascript:logout()">
                                <i class="bi bi-box-arrow-right me-2"></i>退出
                            </a>
                        </li>
                    </ul>
                </div>
                % else:
            <!-- 未登录显示认证按钮 -->
            <div id="authSection">
                <button class="auth-btn btn btn-login" onclick="showModal('login')">登录</button>
                <button class="auth-btn btn btn-register" onclick="showModal('register')">注册</button>
            </div>
            
            % end
        </div>
    </div>
</nav>

<main style="margin-top: 90px;">
    <div class="container">
        <!-- 新增中央标题和按钮 -->
        <div class="hero-section text-center" style="padding-top: 20vh;">
            <h1 class="display-2 fw-bold" style="color: rgba(255,255,255,0.9); 
                text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
                line-height: 1.2;
                margin-bottom: 30px;
                font-family: 'Merriweather', serif;"> <!-- 添加 font-family -->
                Whitenight<br>
                <span style="font-size: 0.8em;">Minecraft Server</span>
            </h1>
            
            <div class="d-flex align-items-center justify-content-center" style="gap: 100px;">
                <a href="https://qm.qq.com/q/xZca4kNJxm" 
                   class="btn btn-login btn-lg px-5 py-3"
                   target="_blank">
                   <i class="bi bi-people me-2"></i> 加入QQ群
                </a>
                <a href="https://docs.qq.com/doc/DQUloeHhXenFPSFRU?u=99dcd78108a04954986069c106e05d39"
                   class="btn btn-register btn-lg px-5 py-3" 
                   target="_blank">
                   <i class="bi bi-file-earmark-text me-2"></i> 查看文档
                </a>
            </div>
        </div>
    </div>
</main>

<!-- 登录注册模态框 -->
<div class="modal fade" id="authModal">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header border-0">
                <h5 class="modal-title">玩家登录</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <form id="authForm" onsubmit="handleSubmit(event)">
                    <!-- 注册专用字段（默认隐藏） -->
                    <div id="registerFields" style="display: none;">
                        <div class="mb-3">
                            <input type="text" id="authUsername" class="form-control"
                                   placeholder="用户名（字母/数字/_/#）">
                        </div>
                        <div class="mb-3">
                            <input type="text" id="authDisplayName" class="form-control"
                                   placeholder="显示名称">
                        </div>
                    </div>
                    
                    <!-- 公共字段 -->
                    <div class="mb-3">
                        <input type="email" id="authEmail" class="form-control"
                               placeholder="电子邮箱" required>
                    </div>
                    <div class="mb-3">
                        <input type="password" id="authPassword" class="form-control"
                               placeholder="密码" required>
                    </div>
                    <button type="submit" class="btn btn-lg btn-login w-100">确认</button>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    function handleSubmit(event) {
        event.preventDefault(); // 阻止表单默认提交行为

        // 关闭模态框（如果需要）
        const modal = bootstrap.Modal.getInstance(document.getElementById('authModal'));
        if (modal) {
            modal.hide();
        }

        // 设置 0.5 秒的延迟后刷新页面
        setTimeout(function () {
            window.location.reload(); // 刷新页面
        }, 500); // 500 毫秒 = 0.5 秒
    }
</script>

<!-- 核心脚本 -->
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.bundle.min.js"></script>

<!-- 退出登录处理 -->
<script>
// 增强版退出功能
function secureLogout() {
    // 清除所有Cookie
    document.cookie.split(';').forEach(cookie => {
        const [name] = cookie.split('=');
        document.cookie = `${name.trim()}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
    });
    
    // 强制刷新页面
    window.location.href = '/?logout=' + Date.now() + '&nocache=1';
}

// 绑定退出按钮事件
$(document).ready(function() {
    $(document).on('click', '#logoutButton', function(e) {
        e.preventDefault();
        if (confirm('确定要退出登录吗？')) {
            // 显示加载状态
            $('body').append(`
                <div class="loading-overlay">
                    <div class="spinner-border text-primary"></div>
                    <p>正在退出...</p>
                </div>
            `);
            
            // 执行退出操作
            fetch('/api/logout', { method: 'POST' })
                .finally(() => secureLogout());
        }
    });
});
</script>

<!-- 主应用脚本 -->
<script src="/static/js/app.js"></script>

</body>
</html>把背景改成从1.png到5.png随机获取