<?php
$page_title = 'Superadmin Dashboard';
require_once 'includes/header.php';

// Stats
try {
    $userCount = $pdo->query("SELECT COUNT(*) FROM users")->fetchColumn();
    $shopCount = $pdo->query("SELECT COUNT(*) FROM shops")->fetchColumn();
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}
?>

<!-- Welcome Section -->
<div class="welcome-section">
    <h2>ຍິນດີຕ້ອນຮັບ,
        <?= htmlspecialchars($_SESSION['username'] ?? 'Superadmin') ?>!
    </h2>
    <p>ລະບົບຈັດການສະແກນເຂົ້າ-ອອກ MUANJAI (Superadmin)</p>
</div>

<!-- Stats Grid -->
<div class="stats-grid">
    <div class="stat-card">
        <div class="stat-icon gold">
            <i class="fas fa-users"></i>
        </div>
        <div class="stat-info">
            <h3>
                <?= number_format($userCount) ?>
            </h3>
            <p>ຜູ້ໃຊ້ງານທັງໝົດ</p>
        </div>
    </div>

    <div class="stat-card">
        <div class="stat-icon purple">
            <i class="fas fa-store"></i>
        </div>
        <div class="stat-info">
            <h3>
                <?= number_format($shopCount) ?>
            </h3>
            <p>ຮ້ານຄ້າທັງໝົດ</p>
        </div>
    </div>
</div>

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