<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BlockWatch Dashboard</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <div class="launcher-header">
        <div class="launcher-logo">BlockWatch Console</div>
        <div class="user-info">
            <span class="username">{{.Username}}</span>
            <a class="btn btn-ghost" href="/logout">Выход</a>
        </div>
    </div>
    <div class="container">
        <div class="minecraft-panel">
            <div class="launcher-panel">
                <div class="header">
                    <div>
                        <h1 class="title">Обзор</h1>
                        <p class="description">Телеметрия в реальном времени из ядра BlockWatch. Держите TPS выше 19.5.</p>
                    </div>
                </div>

                <div class="dashboard-grid">
                    {{range .Servers}}
                    <div class="server-card" data-server-id="{{.ID}}">
                        <div class="server-header">
                            <div>
                                <a href="/server/{{.ID}}"><h2>{{.Name}}</h2></a>
                                <span class="muted">{{.Region}} · v{{.Version}}</span>
                            </div>
                            {{if eq .Status "stopped"}}
                            <div class="status-pill status-stopped"><span class="status-text">Остановлен</span></div>
                            {{else if eq .Status "restarting"}}
                            <div class="status-pill status-restarting"><span class="status-text">Перезапуск</span></div>
                            {{else}}
                            <div class="status-pill status-online"><span class="status-text">Онлайн</span></div>
                            {{end}}
                        </div>
                        <div class="metric-row">
                            <div>
                                <span class="metric-label">Игроки</span>
                                <div class="metric-value"><span class="metric-online">{{.Online}}</span>/<span class="metric-max">{{.MaxPlayers}}</span></div>
                            </div>
                            <div>
                                <span class="metric-label">TPS</span>
                                <div class="metric-value"><span class="metric-tps">{{printf "%.1f" .TPS}}</span></div>
                            </div>
                            <div>
                                <span class="metric-label">MSPT</span>
                                <div class="metric-value"><span class="metric-mspt">{{printf "%.1f" .MSPT}}</span> мс</div>
                            </div>
                        </div>
                        <div class="progress-wrap">
                            <div class="progress-label">Нагрузка</div>
                            <div class="progress-bar">
                                <div class="progress-fill" style="width: 0%;"></div>
                            </div>
                        </div>
                    </div>
                    {{end}}
                </div>

                <div class="panel-split">
                    <div class="split-card">
                        <h2 class="section-title">Пульс кластера</h2>
                        <div class="pulse-grid">
                            <div class="pulse-item">
                                <div class="pulse-value" id="pulse-tps">19.8</div>
                                <div class="pulse-label">Средний TPS</div>
                            </div>
                            <div class="pulse-item">
                                <div class="pulse-value" id="pulse-online">68</div>
                                <div class="pulse-label">Онлайн игроков</div>
                            </div>
                            <div class="pulse-item">
                                <div class="pulse-value" id="pulse-mspt">40.5</div>
                                <div class="pulse-label">Средний MSPT</div>
                            </div>
                        </div>
                        <div class="pulse-log" id="pulse-log">
                            <div class="log-line">Ожидаем поток телеметрии...</div>
                        </div>
                    </div>

                    <div class="split-card">
                        <h2 class="section-title">Управление сервером</h2>
                        <p class="muted">Откройте карточку нужного сервера и разверните моды по ссылке.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/js/dashboard.js"></script>
</body>
</html>
