<?php
require_once __DIR__ . '/../app/auth.php';
require_login();
$me = current_user();
?>
<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>Dashboard</title>
  <style>
    body{font-family:system-ui;margin:0;background:#0b1220;color:#e6e6e6}
    .wrap{max-width:980px;margin:0 auto;padding:18px}
    .top{display:flex;justify-content:space-between;align-items:center}
    .card{background:#111a2e;border:1px solid #233055;border-radius:16px;padding:16px;margin-top:14px}
    a{color:#93c5fd}
  </style>
</head>
<body>
  <div class="wrap">
<div class="top" style="margin-bottom:14px;">
  <div>
    <a style="color:#93c5fd;margin-right:12px;" href="/dashboard.php">Dashboard</a>
    <a style="color:#93c5fd;margin-right:12px;" href="/users.php">Users</a>
    <a style="color:#93c5fd;margin-right:12px;" href="/credits.php">Credits</a>
  </div>
  <div><a style="color:#93c5fd" href="/logout.php">Logout</a></div>
</div>
    <div class="top">
      <div>
        <h2 style="margin:0;">Welcome, <?= htmlspecialchars($me['display_name'] ?: $me['username']) ?></h2>
        <div style="opacity:.75;">Role: <?= htmlspecialchars($me['role']) ?></div>
      </div>
      <div><a href="/logout.php">Logout</a></div>
    </div>

    <div class="card">
      <h3 style="margin:0 0 8px 0;">Credits</h3>
      <div style="font-size:28px;font-weight:700;"><?= number_format((float)$me['credits_balance'], 2) ?></div>
      <div style="opacity:.75;">(Users/credits/customers modules come next)</div>
    </div>
  </div>
</body>
</html>
