<?php
// Fetch order count for dashboard
$orders_stmt = $pdo->prepare("SELECT COUNT(*) FROM orders WHERE user_id = ?");
$orders_stmt->execute([$user_id]);
$order_count = $orders_stmt->fetchColumn();
?>

<style>
    .summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 35px; }
    .summary-box { padding: 25px 20px; border-radius: 12px; border: 1px solid var(--border); text-align: center; background: #fafafa; transition: transform 0.2s; }
    .summary-box:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); }
    .summary-box h4 { margin: 0; font-size: 0.85rem; text-transform: uppercase; color: #64748b; letter-spacing: 0.5px; font-weight: 700; }
    .summary-box .val { font-size: 1.8rem; font-weight: 900; color: var(--primary); margin-top: 10px; display: block; }
</style>

<h2 class="section-title">Account Overview</h2>

<div class="summary-grid">
    <div class="summary-box">
        <h4>Available Balance</h4>
        <span class="val">৳<?php echo number_format($user['balance'], 2); ?></span> 
    </div>
    <div class="summary-box">
        <h4>Items Owned</h4>
        <span class="val"><?php echo $order_count; ?></span>
    </div>
    <div class="summary-box">
        <h4>Account Status</h4>
        <span class="val" style="color: #10b981;">Verified</span>
    </div>
</div>

<p style="color: #64748b; font-size: 1rem; line-height: 1.6;">
    Welcome back to your dashboard, <strong><?php echo htmlspecialchars($user['name']); ?></strong>! Here you can manage your digital products, track recent invoices, and get support if you face any issues with your downloads. Use the menu on the left to navigate.
</p>
