<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Realm 转发管理面板</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        button {
            padding: 10px 15px;
            margin: 5px;
            border: none;
            border-radius: 5px;
            background-color: #28a745;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #218838;
        }
        .delete-btn {
            background-color: #dc3545;
        }
        .delete-btn:hover {
            background-color: #c82333;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input, .form-group textarea {
            width: calc(100% - 22px);
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        #output {
            margin-top: 20px;
            background-color: #f8f9fa;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            min-height: 50px;
            white-space: pre-wrap;
        }
        .status-tag {
            display: inline-flex;
            align-items: center;
            padding: 4px 8px;
            font-size: 14px;
            line-height: 20px;
            border-radius: 4px;
            margin-left: 10px;
            font-weight: 500;
        }
        .status-tag.running {
            background-color: #52c41a;
            color: white;
        }
        .status-tag.stopped {
            background-color: #ff4d4f;
            color: white;
        }
        .status-wrapper {
            display: inline-flex;
            align-items: center;
            margin-left: 15px;
        }
        .status-label {
            color: #666;
            margin-right: 8px;
        }
        .button-group {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }
        #logoutButton {
            background-color: #6c757d;
        }
        #logoutButton:hover {
            background-color: #5a6268;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Realm 转发管理面板</h1>

        <div class="button-group">
            <button id="startButton">启动服务</button>
            <button id="stopButton">停止服务</button>
            <button id="restartButton">重启服务</button>
            <button id="logoutButton">登出</button>
            <div class="status-wrapper">
                <span class="status-label">状态:</span>
                <span id="serviceStatus" class="status-tag">检查中...</span>
            </div>
        </div>

        <div id="output"></div>

        <h2>当前转发规则</h2>
        <table id="forwardingTable">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>中转端口</th>
                    <th>落地机 IP</th>
                    <th>目标端口</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <!-- 动态填充转发规则 -->
            </tbody>
        </table>

        <h2>添加转发规则</h2>
        <div class="form-group">
            <label for="localPort">中转端口:</label>
            <input type="number" id="localPort" required>
        </div>
        <div class="form-group">
            <label for="remoteIP">落地机 IP:</label>
            <input type="text" id="remoteIP" required>
        </div>
        <div class="form-group">
            <label for="remotePort">目标端口:</label>
            <input type="number" id="remotePort" required>
        </div>
        <button id="addRuleButton">添加规则</button>

        <h2>批量添加转发规则</h2>
        <div class="form-group">
            <label for="rulesInput">请输入转发规则(每行一个规则):</label>
            <p>IPv4 格式:中转端口:落地机IP:目标端口</p>
            <p>IPv6 格式:中转端口:[落地机IPv6]:目标端口</p>
            <textarea id="rulesInput" rows="5"></textarea>
        </div>
        <button id="addBatchRulesButton">批量添加规则</button>
    </div>

    <script src="/static/app.js"></script>
</body>
</html>