<?php
session_start();
include '../config.php';
if(!isset($_SESSION['mc_username'])) { header("Location: login.php"); exit; }
$user = $_SESSION['mc_username'];
$orders = $pdo->prepare("SELECT * FROM orders WHERE mc_username = ? ORDER BY created_at DESC");
$orders->execute([$user]);
?>
<!DOCTYPE html>
<html>
<head><title>My Orders • <?=htmlspecialchars($user)?></title></head>
<body style="background:#0a0a1a;color:#0f0;font-family:courier;padding:3rem">
<div style="max-width:1000px;margin:auto;background:#111;border:3px solid #0f0;padding:2rem;border-radius:15px">
    <h1>My Orders</h1>
    <a href="index.php">Dashboard</a> • <a href="logout.php">Logout</a>
    <table width="100%" style="margin-top:2rem;border-collapse:collapse">
        <tr style="background:#000"><th>ID</th><th>Date</th><th>Total</th><th>Status</th></tr>
        <?php while($o = $orders->fetch()): ?>
        <tr style="border-bottom:1px solid #333">
            <td>#<?=$o['id']?></td>
            <td><?=$o['created_at']?></td>
            <td>$<?=$o['total']?></td>
            <td><span style="color:#0f0"><?=ucfirst($o['status'])?></span></td>
        </tr>
        <?php endwhile; ?>
    </table>
    <?php if($orders->rowCount()==0) echo "<p>No orders yet!</p>"; ?>
</div>
</body>
</html>