<?php
require_once 'header.php';

$db = getDB();
$stmt = $db->query("SELECT * FROM items ORDER BY FIELD(rarity, 'legendary', 'epic', 'rare', 'uncommon', 'common')");
$items = $stmt->fetchAll();
?>

<h2 class="text-center mb-20" style="color: var(--gold);">🎒 Champion's Satchel</h2>

<div class="inventory-grid">
    <?php if (empty($items)): ?>
        <p style="color: #666; text-align: center; grid-column: 1/-1;">Inventory is empty</p>
    <?php else: ?>
        <?php foreach ($items as $item): ?>
            <div class="inventory-slot rarity-<?php echo $item['rarity']; ?>" 
                 onmouseenter="showTooltip(event, <?php echo htmlspecialchars(json_encode($item)); ?>)" 
                 onmouseleave="hideTooltip()"
                 onclick="useItem(<?php echo $item['id']; ?>)">
                <?php if ($item['image_path']): ?>
                    <img src="<?php echo $item['image_path']; ?>" alt="<?php echo $item['name']; ?>">
                <?php else: ?>
                    <span style="font-size: 2rem;">📦</span>
                <?php endif; ?>
                <?php if ($item['quantity'] > 1): ?>
                    <span class="item-quantity"><?php echo $item['quantity']; ?></span>
                <?php endif; ?>
            </div>
        <?php endforeach; ?>
    <?php endif; ?>
</div>

<?php require_once 'footer.php'; ?>


