<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ScytheNet</title>
    <style>
        body {
            background-color: #000;
            color: #fff;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
        }
        .container {
            display: flex;
            height: 100vh;
        }
        .logo {
            font-size: 24px;
            font-weight: bold;
            color: #fff;
            padding: 10px;
            background-color: #333;
            display: inline-block;
            cursor: pointer;
            margin-bottom: 20px;
            text-align: center;
        }
        .logo span {
            color: red;
        }
        .sidebar {
            width: 200px;
            background-color: #1a1a1a;
            display: flex;
            flex-direction: column;
            padding-top: 20px;
            align-items: center;
        }
        .sidebar button {
            background-color: #333;
            color: #fff;
            border: none;
            padding: 15px;
            font-size: 18px;
            cursor: pointer;
            margin-bottom: 10px;
            text-align: left;
            width: 100%;
        }
        .sidebar button:hover {
            background-color: #9c149c;
        }
        .sidebar button.active {
            background-color: #9c149c;
        }
        .content {
            flex: 1;
            padding: 20px;
            background-color: #222;
        }
        .button {
            background-color: #9c149c;
            color: white;
            border: none;
            padding: 15px 20px;
            font-size: 18px;
            cursor: pointer;
            margin-top: 20px;
            width: 100%;
        }
        .button:hover {
            background-color: #9c149c;
        }
        input, label {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            font-size: 16px;
            border: 1px solid #fff;
            background-color: #1a1a1a;
            color: #fff;
        }
        h1 {
            color: #ecf0f1;
            font-size: 24px;
        }
        .emoji {
            font-size: 24px;
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <div class="logo" onclick="showDashboard()">Scythe<span>NET</span></div>
            <button onclick="showDashboard()" id="dashboardBtn">🖥️ Dashboard</button>
            <button onclick="showAPI()" id="apiBtn">🔑 API</button>
            <button onclick="showAttack()" id="attackBtn">💥 Attack</button>
        </div>
        <div class="content" id="content">
            <h1>Willkommen bei ScytheNet</h1>
            <p>Wählen Sie eine Option aus der Seitenleiste</p>
        </div>
    </div>

    <script>
        function resetActiveButtons() {
            document.querySelectorAll('.sidebar button').forEach(button => {
                button.classList.remove('active');
            });
        }

        function showDashboard() {
            resetActiveButtons();
            document.getElementById('dashboardBtn').classList.add('active');
            document.getElementById('content').innerHTML = `
                <h1>Dashboard</h1>
                <p>Online Nutzer: <span id="online_count">-</span></p>
                <p>Weltkarte: 🌍</p>
                <p>Pakete gesendet: 0</p>
                <p>Pakete empfangen: 0</p>
                <button class="button" onclick="fetchOnlineCount()">Online abrufen</button>
            `;
        }

        function showAPI() {
            resetActiveButtons();
            document.getElementById('apiBtn').classList.add('active');
            document.getElementById('content').innerHTML = `
                <h1>API Einstellungen</h1>
                <label for="api_key">API Key:</label>
                <input type="text" id="api_key" placeholder="Geben Sie Ihren API Key ein">
                <button class="button" onclick="saveAPIKey()">Speichern</button>
            `;
        }

        function showAttack() {
            resetActiveButtons();
            document.getElementById('attackBtn').classList.add('active');
            document.getElementById('content').innerHTML = `
                <h1>Angriff</h1>
                <label for="ip">IP-Adresse:</label>
                <input type="text" id="ip" placeholder="Geben Sie die IP-Adresse ein">
                <label for="port">Port:</label>
                <input type="text" id="port" placeholder="Geben Sie den Port ein">
                <label for="duration">Dauer:</label>
                <input type="text" id="duration" placeholder="Geben Sie die Dauer ein">
                <button class="button" onclick="startAttack()">Angriff starten</button>
            `;
        }

        function fetchOnlineCount() {
            fetch('http://localhost:8081/online')
                .then(response => response.text())
                .then(data => {
                    document.getElementById('online_count').innerText = data;
                });
        }

        function saveAPIKey() {
            const apiKey = document.getElementById('api_key').value;
            // Hier würde dein C-Backend aufgerufen, um den API-Schlüssel zu speichern.
            alert('API Key gespeichert: ' + apiKey);
        }

        function startAttack() {
            const ip = document.getElementById('ip').value;
            const port = document.getElementById('port').value;
            const duration = document.getElementById('duration').value;
            // Hier würde dein C-Backend aufgerufen, um den Angriff zu starten.
            alert('Angriff auf ' + ip + ':' + port + ' für ' + duration + ' Sekunden gestartet!');
        }
    </script>
</body>
</html>