<?php
ini_set('display_errors', 1);
if(session_status() === PHP_SESSION_NONE) session_start();
include(__DIR__ . '/functions.php');

$log_check = $db->select('users', '*', 'id = :id', '', [':id' => 1]);
$loggedinuser = !empty($log_check) ? $log_check[0]['username'] : null;
if (empty($loggedinuser) && isset($_SESSION['name']) && $_SESSION['name'] === $loggedinuser) {
	header("Location: index.php");
	exit;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="author" content="Bet3">
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
	<link href="css/themes/darkly/bootstrap.css" rel="stylesheet" title="main">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
	<link href="css/simple-sidebar.css" rel="stylesheet">
	<style>
		:root {
			--primary-red: #8B0000;
			--dark-red: #6D0000;
			--light-red: #FF0000;
			--black: #0A0A0A;
			--dark-gray: #1A1A1A;
			--text-light: #F8F9FA;
		}
		
		body {
			background: linear-gradient(135deg, var(--black) 0%, var(--dark-red) 100%);
			color: var(--text-light);
			min-height: 100vh;
			background-attachment: fixed;
			font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
		}
		
		#particles-js {
			position: fixed;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
			z-index: -1;
			background: transparent;
		}
		
		.particles-js-canvas-el {
			position: fixed;
		}
		
		#sidebar-wrapper {
			background: linear-gradient(to bottom, var(--black), var(--dark-red));
			box-shadow: 3px 0 15px rgba(0, 0, 0, 0.5);
			border-right: 1px solid var(--light-red);
		}
		
		.sidebar-heading {
			background: linear-gradient(to right, var(--black), var(--dark-red));
			color: var(--text-light);
			padding: 20px 15px;
			font-size: 1.3rem;
			font-weight: bold;
			text-align: center;
			border-bottom: 2px solid var(--light-red);
			text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
		}
		
		.list-group-item {
			background-color: transparent;
			border: none;
			color: #EEE;
			padding: 15px 20px;
			margin: 5px 0;
			border-radius: 0;
			transition: all 0.3s ease;
		}
		
		.list-group-item:hover {
			background: linear-gradient(to right, var(--dark-red), transparent);
			color: #FFF;
			padding-left: 25px;
			border-left: 3px solid var(--light-red);
		}
		
		.list-group-item i {
			color: var(--light-red);
			width: 25px;
		}
		
		.navbar {
			background: linear-gradient(to right, var(--black), var(--dark-red));
			box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
			border-bottom: 1px solid var(--light-red);
		}
		
		#menu-toggle {
			background: linear-gradient(to right, var(--dark-red), var(--primary-red));
			border: none;
			border-radius: 50%;
			width: 40px;
			height: 40px;
			display: flex;
			align-items: center;
			justify-content: center;
			box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
		}
		
		#menu-toggle:hover {
			background: linear-gradient(to right, var(--primary-red), var(--light-red));
			transform: scale(1.05);
		}
		
		.btn-danger {
			background: linear-gradient(to bottom, var(--dark-red), var(--primary-red));
			border: none;
			border-radius: 20px;
			transition: all 0.3s;
		}
		
		.btn-danger:hover {
			background: linear-gradient(to bottom, var(--primary-red), var(--light-red));
			transform: translateY(-2px);
			box-shadow: 0 4px 8px rgba(255, 0, 0, 0.3);
		}
		
		#pageMessages {
			left: 50%;
			transform: translateX(-50%);
			position: fixed;
			text-align: center;
			top: 5px;
			width: 60%;
			z-index: 9999;
			border-radius: 5px;
			box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
		}
		
		.alert {
			position: relative;
			background: linear-gradient(to right, var(--dark-red), var(--primary-red));
			color: white;
			border: none;
			border-left: 4px solid var(--light-red);
		}
		
		.alert .close {
			position: absolute;
			top: 5px;
			right: 5px;
			font-size: 1em;
			color: white;
		}
		
		.alert .fa {
			margin-right: .3em;
		}
		
		.container-fluid {
			background: rgba(10, 10, 10, 0.7);
			border-radius: 10px;
			padding: 20px;
			margin-top: 20px;
			box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
			border: 1px solid rgba(139, 0, 0, 0.3);
		}
		
		/* Efeito de brilho sutil em elementos importantes */
		.glow {
			text-shadow: 0 0 5px rgba(255, 0, 0, 0.3);
		}
		
		/* Responsividade */
		@media (max-width: 768px) {
			#wrapper {
				flex-direction: column;
			}
			#sidebar-wrapper {
				width: 100%;
				position: fixed;
				top: 0;
				left: -100%;
				height: 100vh;
				transition: all 0.5s ease;
				z-index: 1050;
				box-shadow: 3px 0 15px rgba(0, 0, 0, 0.7);
			}
			#wrapper.toggled #sidebar-wrapper {
				left: 0;
			}
			#page-content-wrapper {
				padding-top: 60px;
				margin-left: 0;
			}
			#menu-toggle {
				display: block !important;
			}
			.navbar {
				position: fixed;
				width: 100%;
				top: 0;
				z-index: 1040;
			}
			.container-fluid {
				margin: 10px;
				padding: 15px;
			}
			#pageMessages {
				width: 90%;
				font-size: 0.9em;
			}
		}
	</style>
</head>
<body>
	<div id="js-particles"></div>

	<div class="d-flex" id="wrapper">
		<div class="" id="sidebar-wrapper">
			<div class="sidebar-heading">IBO4K SavimaleDEV</div>
			<span><a class="list-grup-item" href="https://t.me/bet3inc" target="_blank" style="color: #EEE; padding: 10px; display: block; text-align: center;">&copy; <?=date("Y")?> * SavimaleDEV * </a></span>
			<div class="list-group list-group-flush">
				<a class="list-group-item list-group-item-action" href="dns.php">
					<i class="fa fa-server"></i>&nbsp;&nbsp; SERVIDORES
				</a>
				
				<a class="list-group-item list-group-item-action" href="actusers.php">
					<i class="fa fa-users"></i>&nbsp;&nbsp; CONECTADOS
				</a>
				
				<a class="list-group-item list-group-item-action" href="chatbot.php">
					<i class="fa-solid fa-robot"></i>&nbsp;&nbsp; TESTE AUTOMATICO
				</a>

				<a class="list-group-item list-group-item-action" href="logo.php">
					<i class="fa fa-image"></i>&nbsp;&nbsp; ALTERAR LOGOTIPO
				</a>
				
				<a class="list-group-item list-group-item-action" href="bg.php">
					<i class="fa fa-paint-brush"></i>&nbsp;&nbsp; ALTERAR FUNDO
				</a>
				
				<a class="list-group-item list-group-item-action" href="user.php">
					<i class="fa fa-user"></i>&nbsp;&nbsp; PERFIL
				</a>
			</div>
		</div>
		<div id="page-content-wrapper">
			<nav class="navbar navbar-expand-lg navbar-dark">
				<button class="btn btn-primary" id="menu-toggle">
					<i class="fas fa-bars"></i>
				</button>
				
				&nbsp;&nbsp;
				<div class="center" id="pageMessages"></div>
				<a href="logout.php" class="btn btn-danger ml-auto mr-1">Logout</a>
			</nav>

			<div class="container-fluid"><br>