<?php
session_start();

// Verificar se o usuário está logado
if (!isset($_SESSION['eggzie_iboPlayer'])) {
    header('location:login.php');
    exit();
}

// Logout
if (isset($_GET['logout'])) {
    $_SESSION = array();
    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
            $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
    }
    session_destroy();
    header("Location: login.php");
    exit();
}

$IIIIIIIlI1lI = $_SESSION['id'];
$IIIIIIIlI1ll = new SQLite3('a/.eggziepanels.db');
$adb = new SQLite3('./api/.adb.db');
$IIIIIIIlI1l1 = $IIIIIIIlI1ll->query('SELECT * FROM USERS WHERE id=\'1\'');
$IIIIIIIlI11I = $IIIIIIIlI1l1->fetchArray();
$IIIIIIIlI11l = $IIIIIIIlI11I['NAME'];
$IIIIIIIlI111 = $IIIIIIIlI11I['LOGO'];

$IIIIIIIllIII = file_get_contents('./includes/eggzie.json');
$IIIIIIIllIIl = json_decode($IIIIIIIllIII, true);
$IIIIIIIllII1 = $IIIIIIIllIIl['info']['aa'];
?>

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="google" content="notranslate">
    <title><?php echo $IIIIIIIlI11l; ?> - Admin Panel</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Orbitron:400,700|Poppins:300,400,600" rel="stylesheet">
    <link href="css/sb-admin-<?php echo $IIIIIIIllII1; ?>.css" rel="stylesheet">
    
    <style>
        :root {
            --admin-blue: #00d4ff;
            --admin-dark: #06090c;
            --glass: rgba(255, 255, 255, 0.03);
            --border-glass: rgba(0, 212, 255, 0.2);
        }

        body { 
            font-family: 'Poppins', sans-serif; 
            background-color: var(--admin-dark);
            color: #f8f9fc;
        }

        /* Sidebar Command Center */
        .sidebar {
            background: linear-gradient(180deg, #06090c 0%, #0d1218 100%) !important;
            border-right: 1px solid var(--border-glass);
            box-shadow: 5px 0 25px rgba(0, 212, 255, 0.1);
        }

        .sidebar-brand {
            padding: 2.5rem 1rem !important;
        }

        .img-profile-admin {
            border-radius: 15px;
            border: 1px solid var(--admin-blue);
            padding: 10px;
            background: rgba(0, 0, 0, 0.4);
            box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
            transition: 0.3s;
        }

        .img-profile-admin:hover {
            box-shadow: 0 0 35px var(--admin-blue);
            transform: translateY(-3px);
        }

        .admin-tag-box {
            background: var(--glass);
            border: 1px solid var(--border-glass);
            border-radius: 12px;
            padding: 12px;
            margin: 0 15px 20px 15px;
            text-align: center;
        }

        .admin-tag-box span {
            font-family: 'Orbitron', sans-serif;
            color: var(--admin-blue);
            text-shadow: 0 0 10px var(--admin-blue);
            font-size: 13px;
            text-transform: uppercase;
        }

        .nav-item .nav-link {
            margin: 4px 12px;
            border-radius: 8px;
            transition: all 0.3s ease;
            font-size: 0.85rem;
            color: rgba(255,255,255,0.7) !important;
        }

        .nav-item .nav-link i {
            color: var(--admin-blue);
            width: 20px;
            text-align: center;
        }

        .nav-item .nav-link:hover, .nav-item.active .nav-link {
            background: rgba(0, 212, 255, 0.1) !important;
            color: #fff !important;
            box-shadow: 2px 0 0 var(--admin-blue);
        }

        /* Topbar */
        .topbar {
            background: rgba(6, 9, 12, 0.9) !important;
            backdrop-filter: blur(15px);
            border-bottom: 1px solid var(--border-glass);
            height: 4.5rem !important;
        }

        .user-name-top {
            font-family: 'Orbitron', sans-serif;
            color: #fff;
            font-size: 0.9rem;
            letter-spacing: 1px;
        }

        .btn-logout-admin {
            background: transparent;
            border: 1px dashed #ff3e3e;
            color: #ff3e3e !important;
            border-radius: 4px;
            padding: 5px 15px !important;
            font-size: 11px;
            font-weight: bold;
            text-transform: uppercase;
            transition: 0.3s;
        }

        .btn-logout-admin:hover {
            background: #ff3e3e;
            color: #fff !important;
            box-shadow: 0 0 15px rgba(255, 62, 62, 0.4);
        }

        #content-wrapper { background-color: #06090c; }
        .sidebar-divider { border-top: 1px solid var(--border-glass); opacity: 0.3; }
    </style>
</head>

<body id="page-top">
    <div id="wrapper">
        <ul class="navbar-nav sidebar sidebar-dark accordion" id="accordionSidebar">
            
            <a class="sidebar-brand d-flex flex-column align-items-center justify-content-center" href="users.php">
                <div class="sidebar-brand-icon">
                    <img class="img-profile-admin" width="100px" src="<?php echo $IIIIIIIlI111 ?? 'img/logo.png'; ?>" onerror="this.src='img/logo.png';">
                </div>
            </a>

            <div class="admin-tag-box">
                <small style="display:block; font-size: 9px; opacity: 0.5;">SEJA BEM VINDO</small>
                <span>LDS PLAY</span>
            </div>

            <hr class="sidebar-divider">

            <li class="nav-item">
                <a class="nav-link" href="users.php">
                    <i class="fas fa-id-card"></i>
                    <span>Gerenciar Usuários</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="revenda.php">
                    <i class="fas fa-user-tie"></i>
                    <span>Gerenciar Revendas</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="sub_revenda.php">
                    <i class="fas fa-users-cog"></i>
                    <span>Gerenciar Sub Revendas</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="revenda_mensagem.php">
                    <i class="fas fa-comment-dots"></i>
                    <span>Alertas de Sistema</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseAds">
                    <i class="fas fa-ad"></i>
                    <span>Publicidades</span>
                </a>
                <div id="collapseAds" class="collapse" data-parent="#accordionSidebar">
                    <div class="bg-dark py-2 collapse-inner rounded border border-info">
                        <a class="collapse-item text-white" href="ads.php">Enviar Banner</a>
                    </div>
                </div>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="Image.php">
                    <i class="fas fa-image"></i>
                    <span>Imagens de Fundo</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="logo.php">
                    <i class="fas fa-pen-nib"></i>
                    <span>Alterar Logotipo</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="layouts.php">
                    <i class="fas fa-layer-group"></i>
                    <span>Temas</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="snoop.php">
                    <i class="fas fa-search-location"></i>
                    <span>Bisbilhoteiro</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link" href="profile.php">
                    <i class="fas fa-shield-alt"></i>
                    <span>Perfil</span>
                </a>
            </li>

            <div class="text-center d-none d-md-inline mt-4">
                <button class="rounded-circle border-0" id="sidebarToggle" style="background: var(--admin-blue);"></button>
            </div>
        </ul>

        <div id="content-wrapper" class="d-flex flex-column">
            <div id="content">
                <nav class="navbar navbar-expand navbar-light topbar mb-4 static-top">
                    <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3" style="color: var(--admin-blue);">
                        <i class="fa fa-bars"></i>
                    </button>

                    <div class="d-none d-sm-block ml-3">
                        <h6 class="user-name-top m-0">ADM ULTRA: <?php echo strtoupper($IIIIIIIlI11l); ?></h6>
                    </div>

                    <ul class="navbar-nav ml-auto align-items-center">
                        <li class="nav-item">
                            <a class="nav-link btn-logout-admin" href="?logout=true">
                                <span>Logout</span>
                                <i class="fas fa-power-off ml-2"></i>
                            </a>
                        </li>
                    </ul>
                </nav>