<?php
session_start();
include '../config.php';
if(!isset($_SESSION['mc_username'])) { header("Location: login.php"); exit; }
$user = $_SESSION['mc_username'];

$page = $_GET['p'] ?? 'dashboard';
$pages = ['dashboard','orders','profile'];
$page = in_array($page, $pages) ? $page : 'dashboard';
?>
<!DOCTYPE html>
<html>
<head>
    <title><?=ucfirst($page)?> • <?=$user?></title>
    <link href="https://fonts.bunny.net/css?family=Space+Grotesk:wght@500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <style>
        :root{--green:#00ff88;--purple:#e879f9;--bg:#0a0a1a;--card:#161625;--sidebar:#111;}
        body{background:var(--bg);color:#fff;font-family:'Space Grotesk',sans-serif;display:flex;min-height:100vh;margin:0;}
        .sidebar{width:260px;background:var(--sidebar);border-right:3px solid var(--green);position:fixed;height:100%;overflow-y:auto;}
        .sidebar-header{background:var(--purple);padding:2rem;text-align:center;}
        .sidebar-header h2{color:#000;font-size:2rem;font-weight:bold;}
        .sidebar-menu .item a{display:flex;align-items:center;padding:1.2rem 1.8rem;color:#ccc;text-decoration:none;}
        .sidebar-menu .item a:hover,.sidebar-menu .item.active a{background:var(--green);color:#000;}
        .sidebar-menu i{margin-right:15px;font-size:1.4rem;}
        .main{margin-left:260px;padding:2rem;width:100%;}
        .topbar{background:#000;padding:1.2rem 2rem;position:fixed;top:0;left:260px;right:0;z-index:999;border-bottom:3px solid var(--purple);text-align:center;}
        .content{padding-top:90px;}
        .card{background:var(--card);border-radius:20px;padding:2.5rem;margin:1rem 0;box-shadow:0 15px 50px rgba(232,121,249,0.2);}
        h1{color:var(--green);font-size:2.5rem;}
    </style>
</head>
<body>

<div class="sidebar">
    <div class="sidebar-header">
        <h2><?=htmlspecialchars($user)?></h2>
    </div>
    <div class="sidebar-menu">
        <div class="item <?= $page=='dashboard'?'active':'' ?>"><a href="?p=dashboard">Dashboard</a></div>
        <div class="item <?= $page=='orders'?'active':'' ?>"><a href="?p=orders">My Orders</a></div>
        <div class="item <?= $page=='profile'?'active':'' ?>"><a href="?p=profile">Profile</a></div>
        <div class="item"><a href="../index.php">Back to Store</a></div>
        <div class="item"><a href="logout.php">Logout</a></div>
    </div>
</div>

<div class="main">
    <div class="topbar">
        <h3>Reckon Player Panel</h3>
    </div>
    <div class="content">
        <div class="card">
            <?php
            if($page=='dashboard') echo "<h1>Welcome back!</h1><p>This is your player dashboard.</p>";
            elseif($page=='orders') include 'orders.php';
            elseif($page=='profile') echo "<h1>Profile Settings (Coming Soon)</h1>";
            ?>
        </div>
    </div>
</div>
</body>
</html>