<?php
if (!isLoggedIn()) redirect('../login.php');
$userId = getUserId();
$userData = getUserData($userId);
$wallets = getUserWallets($userId);
$siteName = getSiteName();
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($pageTitle) ? $pageTitle . ' - ' : ''; ?><?php echo $siteName; ?></title>
    <link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
    <div class="sidebar">
        <div class="sidebar-logo"><?php echo $siteName; ?></div>
        <ul class="sidebar-menu">
            <li><a href="dashboard.php">📊 Dashboard</a></li>
            <li><a href="withdrawals.php">💰 Withdrawals</a></li>
            <li><a href="downlines.php">👥 Downlines</a></li>
            <li><a href="tasks.php">📝 Tasks</a></li>
            <li><a href="videos.php">🎥 Videos</a></li>
            <li><a href="trivia.php">❓ Trivia</a></li>
            <li><a href="ads.php">📺 Ads</a></li>
            <li><a href="blogs.php">📰 Blogs</a></li>
            <li><a href="profile.php">👤 Profile</a></li>
            <li><a href="logout.php">🚪 Logout</a></li>
        </ul>
    </div>
    <div class="main-content">
        <div class="header">
            <div><button class="hamburger" onclick="toggleSidebar()">☰</button><h2><?php echo isset($pageTitle) ? $pageTitle : 'Dashboard'; ?></h2></div>
            <div style="display:flex;gap:15px;align-items:center">
                <button class="theme-toggle" id="theme-toggle"><span id="theme-icon">🌙</span></button>
                <div style="font-weight:600"><?php echo $userData['username']; ?></div>
            </div>
        </div>
        <?php if ($flash = getFlash()): ?>
            <div class="alert alert-<?php echo $flash['type']; ?>"><?php echo $flash['message']; ?></div>
        <?php endif; ?>
