<?php require_once __DIR__ . '/../includes/auth.php'; requireLogin(['admin','staff']); $user=currentUser(); ?>
<!doctype html>
<html>
<head>
  <meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Dashboard - SHAHANA VEGETABLES</title>
  <link rel="stylesheet" href="../assets/style.css">
</head>
<body>
<div class="layout">
  <aside class="sidebar">
    <div class="brand">SHAHANA VEGitables<small>Admin & Staff Portal</small></div>
    <nav class="nav">
      <a class="active" href="#">Dashboard</a>
      <a href="items.php">Items</a>
      <a href="billing.php">Billing</a>
      <a href="expenses.php">Expenses</a>
      <a href="users.php">Staff & Customers</a>
      <a href="reports.php">Reports</a>
      <?php if ($user['role'] === 'admin'): ?><a href="contacts.php">Contacts</a><?php endif; ?>
    </nav>
  </aside>
  <main class="main">
    <div class="topbar">
      <div>
        <h1 style="margin:0;">Welcome, <?php echo htmlspecialchars($user['full_name']); ?></h1>
        <p style="color:#66725f;">Manage stock, billing, expenses, and customer balances.</p>
      </div>
      <a class="btn btn-secondary" href="logout.php">Logout</a>
    </div>
    <section class="grid grid-4">
      <div class="card stat"><h3>Today's Sales</h3><p>₹ 24,800</p></div>
      <div class="card stat"><h3>Expenses</h3><p>₹ 6,250</p></div>
      <div class="card stat"><h3>Wholesale Bills</h3><p>18 invoices</p></div>
      <div class="card stat"><h3>Pending Collection</h3><p>₹ 14,300</p></div>
    </section>
    <section class="grid grid-2" style="margin-top:20px;">
      <div class="card">
        <h3>Quick Actions</h3>
        <p>Create customer, add item, raise invoice, record installment, add expense.</p>
        <div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:14px;">
          <a class="btn btn-primary" href="billing.php">Create Invoice</a>
          <a class="btn btn-secondary" href="users.php">Add Customer</a>
        </div>
      </div>
      <div class="card">
        <h3>Suggestions Added</h3>
        <ul>
          <li>Low stock alert for fast-moving vegetables</li>
          <li>Daily closing summary for admin</li>
          <li>Customer ledger with installments and purchases</li>
          <li>Profit by item using original price vs sale price</li>
        </ul>
      </div>
    </section>
  </main>
</div>
</body>
</html>
