<!doctypehtml><html lang=en><meta charset=UTF-8><meta content="width=device-width,initial-scale=1"name=viewport><title>Bot Configuration Panel</title><script src=https://cdn.tailwindcss.com></script><link href=https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css rel=stylesheet><style>body{background-color:#1a202c;display:flex;justify-content:center;align-items:center;height:100vh;margin:0}.dashboard{display:none}.active-tab{background-color:#2d3748}.sidebar{height:100vh;overflow-y:auto}.content{height:100vh;overflow-y:auto;width:100%}.tab-pane{display:none}.tab-pane.active{display:block}.config-card{@apply bg-gray-700 p-4 rounded-lg shadow-md transition-all duration-300 ease-in-out;}.config-card:hover{@apply transform scale-102 shadow-lg;}.custom-alert{position:fixed;top:20px;right:20px;display:flex;align-items:center;background-color:#2d3748;border-radius:8px;box-shadow:0 4px 6px rgba(0,0,0,.2);padding:15px;z-index:1000;transition:opacity .5s,transform .5s;color:#fff}.custom-alert.success{border-left:5px solid #48bb78}.custom-alert.error{border-left:5px solid #f56565}.alert-icon{margin-right:15px;font-size:24px;font-weight:700}.custom-alert.success .alert-icon{color:#48bb78}.custom-alert.error .alert-icon{color:#f56565}.custom-alert.fade-out{opacity:0;transform:translateX(100%)}</style><div class="text-white w-full bg-gray-800 max-w-sm p-6 rounded-lg shadow-md"id=loginSection><h2 class="font-bold mb-4 text-center text-2xl"><i class="fas fa-lock"></i> Bot Configuration Login</h2><form id=loginForm><div class=mb-4><label class="block text-gray-300">Email</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"id=emailInput required type=email></div><div class=mb-4><label class="block text-gray-300">Password</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"id=passwordInput required type=password></div><div class="mb-4 text-red-500"id=errorMessage></div><button class="text-white rounded py-2 w-full bg-blue-500"type=submit>Login <i class="fas fa-sign-in-alt"></i></button></form></div><div class="container-fluid dashboard h-full w-full"id=dashboardSection><div class="flex flex-col h-full md:flex-row"><div class="text-white w-full bg-gray-900 md:w-1/5 p-4 sidebar"><h3 class="font-bold text-xl mb-4 text-center"><i class="fas fa-cog"></i> Bot Config</h3><ul class=space-y-2><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#hosting data-tab=hosting><i class="fas fa-server"></i> Hosting</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#fivem data-tab=fivem><i class="fas fa-gamepad"></i> Fivem</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#tickets data-tab=tickets><i class="fas fa-ticket-alt"></i> Tickets</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#verify data-tab=verify><i class="fas fa-user-check"></i> Verify</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#reportbug data-tab=reportbug><i class="fas fa-bug"></i> Report Bug</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#logs data-tab=logs><i class="fas fa-list"></i> Logs</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700"href=#welcome data-tab=welcome><i class="fas fa-handshake"></i> Welcome</a><li><a class="rounded py-2 px-4 bg-gray-800 block hover:bg-gray-700 text-red-500"href=# id=logoutBtn><i class="fas fa-sign-out-alt"></i> Logout</a></ul></div><div class="p-4 w-full content md:w-4/5 overflow-auto tab-content"><div class=tab-pane id=hosting><div class="grid grid-cols-1 gap-6 md:grid-cols-3"><div class="rounded-lg bg-gray-800 p-4 col-span-1"><h3 class="font-bold text-xl mb-4 text-green-500">Server Status</h3><div class=space-y-4><div class="flex items-center justify-between"><span>Server State:</span> <span class="font-bold text-yellow-500"id=serverStatus><i class="fas mr-2 fa-circle"></i>Pending</span></div><div class="flex justify-between"><span>CPU Usage</span> <span class=text-green-400>∞</span></div><div class="h-2.5 rounded-full bg-gray-700 w-full"><div class="h-2.5 rounded-full bg-green-500"style=width:1%></div></div><div class="flex justify-between"><span>Memory</span> <span class=text-blue-400>∞ / ∞</span></div><div class="h-2.5 rounded-full bg-gray-700 w-full"><div class="h-2.5 rounded-full bg-blue-500"style=width:1%></div></div><div class="flex space-x-4"><button class="text-white rounded-lg shadow-md duration-300 ease-in-out flex-1 focus:outline-none focus:ring-2 focus:ring-opacity-75 hover:scale-105 px-5 py-3 transform transition bg-green-500 focus:ring-green-400 hover:bg-green-600"id=startServerBtn><i class="fas mr-2 fa-play"></i>Start Server</button> <button class="text-white rounded-lg shadow-md duration-300 ease-in-out flex-1 focus:outline-none focus:ring-2 focus:ring-opacity-75 hover:scale-105 px-5 py-3 transform transition bg-red-500 focus:ring-red-400 hover:bg-red-600"id=stopServerBtn><i class="fas mr-2 fa-stop"></i>Stop Server</button></div></div></div><div class="rounded-lg bg-gray-800 p-4 col-span-2"><h3 class="font-bold text-xl mb-4 text-green-500">Console Logs</h3><div class="rounded bg-black font-mono h-96 overflow-y-auto p-4 text-sm"id=serverLogs><div class=text-green-400>[22:45:12] Server initialization started...</div><div class=text-yellow-400>[22:45:13] Configuring network interfaces...</div><div class=text-green-400>[22:45:15] Server started successfully.</div><div class=text-green-400>[22:45:21] Server running smoothly.</div><div class=text-yellow-400>[22:45:22] Monitoring network traffic...</div><div class=text-green-400>[22:45:24] Adjusting network settings...</div><div class=text-yellow-400>[22:45:25] Network settings optimized.</div></div></div></div></div><div class=tab-pane id=fivem><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Fivem Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=fivemConfig></div><button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveFivemConfigBtn>Save Configuration</button></div></div><div class=tab-pane id=tickets><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Tickets Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=ticketsConfig><h4 class="font-bold col-span-2 text-lg">Ticket Main</h4><div><label class="block text-gray-300">logs</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=1320759689012711504></div><div><label class="block text-gray-300">staffRole</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=1320759548843397120></div><h4 class="font-bold col-span-2 text-lg">Ticket Categories</h4><div class="flex items-center space-x-2"><input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value="בחינה של גאנג"></div><div class="flex items-center space-x-2"><input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=gang_exam> <button class="text-white rounded bg-red-500 px-2 py-1"><i class="fas fa-trash"></i></button></div><div class="flex items-center space-x-2"><input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=היי> <button class="text-white rounded bg-red-500 px-2 py-1"><i class="fas fa-trash"></i></button></div><div class="flex items-center space-x-2"><input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=fdfdfdfdfd> <button class="text-white rounded bg-red-500 px-2 py-1"><i class="fas fa-trash"></i></button></div></div><button class="text-white rounded py-2 mt-4 px-4 bg-blue-500"id=addTicketCategoryBtn>Add Category</button> <button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveTicketsConfigBtn>Save Configuration</button></div></div><div class=tab-pane id=verify><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Verify Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=verifyConfig><div><label class="block text-gray-300">verifyRole</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=123456789012345678></div><div><label class="block text-gray-300">verifyChannel</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=987654321098765432></div></div><button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveVerifyConfigBtn>Save Configuration</button></div></div><div class=tab-pane id=reportbug><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Report Bug Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=reportBugConfig><div><label class="block text-gray-300">bugReportChannel</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=112233445566778899></div><div><label class="block text-gray-300">bugReportRole</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=998877665544332211></div></div><button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveReportBugConfigBtn>Save Configuration</button></div></div><div class=tab-pane id=logs><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Logs Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=logsConfig><div><label class="block text-gray-300">logChannel</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=223344556677889900></div><div><label class="block text-gray-300">logRole</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=009988776655443322></div></div><button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveLogsConfigBtn>Save Configuration</button></div></div><div class=tab-pane id=welcome><div class="text-white rounded-lg shadow-md bg-gray-800 p-6 h-full"><h3 class="font-bold text-xl">Welcome Configuration</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2"id=welcomeConfig><div><label class="block text-gray-300">welcomeChannel</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=334455667788990011></div><div><label class="block text-gray-300">welcomeRole</label> <input class="text-white rounded py-2 w-full bg-gray-700 border px-3"value=110099887766554433></div></div><button class="text-white rounded py-2 mt-4 px-4 bg-green-500"id=saveWelcomeConfigBtn>Save Configuration</button></div></div></div></div></div><script>let token = null;
        let currentUserId = null;
        const apiurl = `https://span-injuries-pockets-translator.trycloudflare.com`;
        let config = {};
        const loginSection = document.getElementById('loginSection');
        const dashboardSection = document.getElementById('dashboardSection');
        const loginForm = document.getElementById('loginForm');
        const errorMessage = document.getElementById('errorMessage');
        const logoutBtn = document.getElementById('logoutBtn');
        const saveFivemConfigBtn = document.getElementById('saveFivemConfigBtn');
        const saveTicketsConfigBtn = document.getElementById('saveTicketsConfigBtn');
        const saveVerifyConfigBtn = document.getElementById('saveVerifyConfigBtn');
        const saveReportBugConfigBtn = document.getElementById('saveReportBugConfigBtn');
        const saveLogsConfigBtn = document.getElementById('saveLogsConfigBtn');
        const saveWelcomeConfigBtn = document.getElementById('saveWelcomeConfigBtn');
        const addTicketCategoryBtn = document.getElementById('addTicketCategoryBtn');
        const startServerBtn = document.getElementById('startServerBtn');
        const stopServerBtn = document.getElementById('stopServerBtn');
        const serverStatus = document.getElementById('serverStatus');
        const serverLogs = document.getElementById('serverLogs');
    
        loginForm.addEventListener('submit', async (e) => {
            e.preventDefault();
            const email = document.getElementById('emailInput').value;
            const password = document.getElementById('passwordInput').value;
    
            try {
                const response = await fetch(`https://true-marginally-bat.ngrok-free.app/login`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({ email, password })
                });
    
                const data = await response.json();
    
                if (data.token) {
                    token = data.token;
                    currentUserId = data.id;
    
                    loginSection.style.display = 'none';
                    dashboardSection.style.display = 'flex';
                    loadConfig();
                    showTab('hosting');
                    updateServerStatus();
                } else {
                    errorMessage.textContent = 'Invalid email or password';
                }
            } catch (error) {
                errorMessage.textContent = 'Login failed. Please try again.';
            }
        });
    
        logoutBtn.addEventListener('click', () => {
            token = null;
            currentUserId = null;
            loginSection.style.display = 'block';
            dashboardSection.style.display = 'none';
        });
    
        async function loadConfig() {
            if (!apiurl) {
                errorMessage.textContent = 'Failed to get API.';
                return;
            }
    
            try {
                const response = await fetch(`${apiurl}/config`, {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
    
                if (!response.ok) {
                    throw new Error('Failed to load config');
                }
    
                config = await response.json();
                renderConfig();
            } catch (error) {
                console.error('Failed to load config:', error);
                errorMessage.textContent = 'Failed to load config.';
            }
        }
    
        function renderConfig() {
            renderFivemConfig();
            renderTicketsConfig();
            renderVerifyConfig();
            renderReportBugConfig();
            renderLogsConfig();
            renderWelcomeConfig();
        }
    
        function renderFivemConfig() {
            const fivemConfig = document.getElementById('fivemConfig');
            fivemConfig.innerHTML = `
                <h4 class="col-span-2 text-lg font-bold">Main Settings</h4>
                ${Object.entries(config.Main || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input 
                            type="text" 
                            class="w-full px-3 py-2 border rounded bg-gray-700 text-white" 
                            value="${value}"
                            onchange="updateConfig('Main', '${key}', this.value)"
                        >
                    </div>
                `).join('')}
    
                <h4 class="col-span-2 text-lg font-bold">Player List Settings</h4>
                ${Object.entries(config.playerList || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input 
                            type="text" 
                            class="w-full px-3 py-2 border rounded bg-gray-700 text-white" 
                            value="${value}"
                            onchange="updateConfig('playerList', '${key}', this.value)"
                        >
                    </div>
                `).join('')}
    
                <h4 class="col-span-2 text-lg font-bold">Top Players Settings</h4>
                ${Object.entries(config.topPlayers || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input 
                            type="text" 
                            class="w-full px-3 py-2 border rounded bg-gray-700 text-white" 
                            value="${value}"
                            onchange="updateConfig('topPlayers', '${key}', this.value)"
                        >
                    </div>
                `).join('')}
    
                <h4 class="col-span-2 text-lg font-bold">Commands Settings</h4>
                ${Object.entries(config.Commands || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input 
                            type="text" 
                            class="w-full px-3 py-2 border rounded bg-gray-700 text-white" 
                            value="${value}"
                            onchange="updateConfig('Commands', '${key}', this.value)"
                        >
                    </div>
                `).join('')}
            `;
        }
    
        function renderTicketsConfig() {
            const ticketsConfig = document.getElementById('ticketsConfig');
            ticketsConfig.innerHTML = `
                <h4 class="col-span-2 text-lg font-bold">Ticket Main</h4>
                ${Object.entries(config.ticketRoles || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('ticketRoles', '${key}', this.value)">
                    </div>
                `).join('')}
                <h4 class="col-span-2 text-lg font-bold">Ticket Categories</h4>
                ${config.ticketCategories.map((category, index) => `
                    <div class="flex items-center space-x-2">
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${category.label}" 
                               onchange="updateTicketCategory(${index}, 'label', this.value)">
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${category.value}" 
                               onchange="updateTicketCategory(${index}, 'value', this.value)">
                        <button class="bg-red-500 text-white px-2 py-1 rounded" onclick="removeTicketCategory(${index})">
                            <i class="fas fa-trash"></i>
                        </button>
                    </div>
                `).join('')}
            `;
        }
    
        function renderVerifyConfig() {
            const verifyConfig = document.getElementById('verifyConfig');
            verifyConfig.innerHTML = `
                ${Object.entries(config.verify || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('verify', '${key}', this.value)">
                    </div>
                `).join('')}
            `;
        }
    
        function renderReportBugConfig() {
            const reportBugConfig = document.getElementById('reportBugConfig');
            reportBugConfig.innerHTML = `
                ${Object.entries(config.reportbug || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('reportbug', '${key}', this.value)">
                    </div>
                `).join('')}
            `;
        }
    
        function renderLogsConfig() {
            const logsConfig = document.getElementById('logsConfig');
            logsConfig.innerHTML = `
                ${Object.entries(config.logs || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('logs', '${key}', this.value)">
                    </div>
                `).join('')}
                ${Object.entries(config.logs.EMBED_COLORS || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('logs.EMBED_COLORS', '${key}', this.value)">
                    </div>
                `).join('')}
            `;
        }
    
        function renderWelcomeConfig() {
            const welcomeConfig = document.getElementById('welcomeConfig');
            welcomeConfig.innerHTML = `
                ${Object.entries(config.welcome || {}).map(([key, value]) => `
                    <div>
                        <label class="block text-gray-300">${key}</label>
                        <input type="text" class="w-full px-3 py-2 border rounded bg-gray-700 text-white" value="${value}" 
                               onchange="updateConfig('welcome', '${key}', this.value)">
                    </div>
                `).join('')}
            `;
        }
    
        function updateConfig(section, key, value) {
            if (!config[section]) {
                config[section] = {};
            }
            config[section][key] = value;
        }
    
        function updateTicketCategory(index, key, value) {
            config.ticketCategories[index][key] = value;
        }
    
        function removeTicketCategory(index) {
            config.ticketCategories.splice(index, 1);
            renderTicketsConfig();
        }
    
        addTicketCategoryBtn.addEventListener('click', () => {
            config.ticketCategories.push({ label: '', value: '' });
            renderTicketsConfig();
        });
    
        saveFivemConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        saveTicketsConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        saveVerifyConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        saveReportBugConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        saveLogsConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        saveWelcomeConfigBtn.addEventListener('click', async () => {
            await saveConfig();
        });
    
        async function saveConfig() {
            try {
                const response = await fetch(`${apiurl}/config`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${token}`
                    },
                    body: JSON.stringify(config)
                });
    
                const data = await response.json();
    
                if (data.success) {
                    showAlert(`Configuration saved successfully!`, 'success');
                } else {
                    showAlert('Failed to save configuration.', 'error');
                }
            } catch (error) {
                showAlert('Failed to save configuration.', 'error');
            }
        }
    
        document.querySelectorAll('[data-tab]').forEach(tab => {
            tab.addEventListener('click', (e) => {
                e.preventDefault();
                const target = e.currentTarget.getAttribute('data-tab');
    
                document.querySelectorAll('.tab-pane').forEach(pane => {
                    pane.classList.remove('show', 'active');
                });
    
                document.querySelectorAll('[data-tab]').forEach(tab => {
                    tab.classList.remove('active-tab');
                });
    
                document.getElementById(target).classList.add('show', 'active');
                document.getElementById(target).classList.add('active');
                e.currentTarget.classList.add('active-tab');
            });
        });
    
        function showTab(tabId) {
            document.querySelectorAll('.tab-pane').forEach(pane => {
                pane.classList.remove('show', 'active');
            });
    
            document.querySelectorAll('[data-tab]').forEach(tab => {
                tab.classList.remove('active-tab');
            });
    
            document.getElementById(tabId).classList.add('show', 'active');
            document.getElementById(tabId).classList.add('active');
            document.querySelector(`[data-tab="${tabId}"]`).classList.add('active-tab');
        }
    
        startServerBtn.addEventListener('click', async () => {
            await controlServer('start');
        });
    
        stopServerBtn.addEventListener('click', async () => {
            await controlServer('stop');
        });
    
        function showAlert(message, type) {
            const alertContainer = document.createElement('div');
            alertContainer.classList.add('custom-alert');
            alertContainer.classList.add(type);
    
            const icon = document.createElement('div');
            icon.classList.add('alert-icon');
            icon.innerHTML = type === 'success' ? '✓' : '✗';
    
            const messageElement = document.createElement('div');
            messageElement.classList.add('alert-message');
            messageElement.textContent = message;
    
            alertContainer.appendChild(icon);
            alertContainer.appendChild(messageElement);
    
            document.body.appendChild(alertContainer);
    
            setTimeout(() => {
                alertContainer.classList.add('fade-out');
                setTimeout(() => {
                    document.body.removeChild(alertContainer);
                }, 500);
            }, 3000);
        }
    
        async function controlServer(action) {
            try {
                const response = await fetch(`${apiurl}/${action}/${currentUserId}`, {
                    method: 'POST',
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
    
                const data = await response.text();
    
                if (response.ok) {
                    showAlert(`Server ${action}ed successfully`, 'success');
                    updateServerStatus();
                } else {
                    showAlert(`Failed to ${action} server: ${data}`, 'error');
                }
            } catch (error) {
                showAlert(`Failed to ${action} server.`, 'error');
            }
        }
    
        function clearConsole() {
            console.clear();
        }
        setInterval(clearConsole, 100);
    
        async function updateServerStatus() {
            try {
                const response = await fetch(`${apiurl}/status/${currentUserId}`, {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
    
                const data = await response.json();
    
                const serverStatusEl = document.getElementById('serverStatus');
                const memoryUsageEl = document.querySelector('#hosting .text-blue-400');
                const memoryProgressEl = document.querySelector('#hosting .bg-blue-500');
                const cpuUsageEl = document.querySelector('#hosting .text-green-400');
                const cpuProgressEl = document.querySelector('#hosting .bg-green-500');
                const serverLogsEl = document.getElementById('serverLogs');
    
                function calculateMemoryPercentage(memoryInMB) {
                    if (memoryInMB <= 300) return 1;
                    const percentage = Math.min((memoryInMB / 16000 * 100), 100);
                    return Math.max(percentage, 1);
                }
    
                if (data.status === 'online') {
                    serverStatusEl.innerHTML = '<i class="fas fa-circle mr-2"></i>Online';
                    serverStatusEl.classList.remove('text-red-500', 'text-yellow-500');
                    serverStatusEl.classList.add('text-green-500');
    
                    cpuUsageEl.textContent = `${data.cpu}%`;
                    cpuProgressEl.style.width = `${data.cpu}%`;
    
                    const memoryInMB = parseFloat(data.memory);
                    const totalMemory = "∞"; 
                    
                    memoryUsageEl.textContent = `${memoryInMB.toFixed(2)} / ${totalMemory} MB`;
                    
                    const memoryPercentage = calculateMemoryPercentage(memoryInMB);
                    memoryProgressEl.style.width = `${memoryPercentage}%`;
                } else {
                    serverStatusEl.innerHTML = '<i class="fas fa-circle mr-2"></i>Offline';
                    serverStatusEl.classList.remove('text-green-500', 'text-yellow-500');
                    serverStatusEl.classList.add('text-red-500');
    
                    cpuUsageEl.textContent = '0%';
                    cpuProgressEl.style.width = '0%';
                    memoryUsageEl.textContent = '0 / ∞ MB';
                    memoryProgressEl.style.width = '1%';
                }
    
                serverLogsEl.innerHTML = data.logs.map(log => {
                    let logClass = 'text-green-400';
                    if (log.includes('error') || log.includes('Error')) {
                        logClass = 'text-red-400';
                    } else if (log.includes('warn') || log.includes('Warning')) {
                        logClass = 'text-yellow-400';
                    }
                    
                    return `<div class="${logClass}">[${new Date().toLocaleTimeString()}] ${log}</div>`;
                }).join('');
            } catch (error) {
                console.error('Failed to update server status', error);
                
                const serverStatusEl = document.getElementById('serverStatus');
                serverStatusEl.innerHTML = '<i class="fas fa-circle mr-2"></i>Offline';
                serverStatusEl.classList.remove('text-green-500', 'text-yellow-500');
                serverStatusEl.classList.add('text-red-500');
    
                document.querySelector('#hosting .text-green-400').textContent = '0%';
                document.querySelector('#hosting .bg-green-500').style.width = '0%';
                document.querySelector('#hosting .text-blue-400').textContent = '0 / ∞ MB';
                document.querySelector('#hosting .bg-blue-500').style.width = '1%';
            }
        }
    
        document.addEventListener('DOMContentLoaded', () => {
            document.getElementById('startServerBtn').addEventListener('click', () => controlServer('start'));
            document.getElementById('stopServerBtn').addEventListener('click', () => controlServer('stop'));
    
            updateServerStatus();
    
            setInterval(updateServerStatus, 5000);
        });</script>