<?php $PAGE_TITLE='Admin'; require __DIR__.'/_layout.php';
$s=[
'users'=>$pdo->query("SELECT COUNT(*) c FROM users WHERE role='user'")->fetch()['c'],
'orders'=>$pdo->query("SELECT COUNT(*) c FROM orders")->fetch()['c'],
'today_orders'=>$pdo->query("SELECT COUNT(*) c FROM orders WHERE DATE(created_at)=CURDATE()")->fetch()['c'],
'revenue'=>$pdo->query("SELECT COALESCE(SUM(price),0) c FROM orders WHERE status='success'")->fetch()['c'],
'total_recharge'=>$pdo->query("SELECT COALESCE(SUM(amount),0) c FROM recharges WHERE status='approved'")->fetch()['c'],
'pending_recharges'=>$pdo->query("SELECT COUNT(*) c FROM recharges WHERE status='pending'")->fetch()['c'],
'pending_orders'=>$pdo->query("SELECT COUNT(*) c FROM orders WHERE status='pending'")->fetch()['c'],
];
$pending_recharges=(int)$s['pending_recharges'];
$pending_orders=(int)$s['pending_orders'];
$shortcuts=[
 ['reports.php','📈','রিপোর্ট',0],
 ['customers.php','👥','কাস্টমার',0],
 ['orders.php','📦','অর্ডার',$pending_orders],
 ['apis.php','🔌','API সমূহ',0],
 ['services.php','🎯','সার্ভিস',0],
 ['recharges.php','💰','রিচার্জ রিকোয়েস্ট',$pending_recharges],
 ['recharge_methods.php','💳','রিচার্জ মেথড',0],
 ['notices.php','📢','নোটিশ',0],
 ['maintenance.php','🧹','মেইনটেন্যান্স',0],
 ['settings.php','⚙️','সেটিংস',0],
];
?>
<div class="admin-hero">
  <div>
    <div class="eyebrow">Admin Overview</div>
    <h2>📊 সারসংক্ষেপ</h2>
    <p>রিচার্জ, অর্ডার, কাস্টমার ও আয়ের দ্রুত রিপোর্ট এক জায়গায়।</p>
  </div>
  <a class="hero-action" href="reports.php">📈 রিপোর্ট দেখুন</a>
</div>

<h2 style="margin-bottom:14px">⚡ দ্রুত অপশন</h2>
<div class="tiles">
<?php foreach($shortcuts as $i=>$sc): ?>
  <a class="tile<?=$i===0?' featured':''?>" href="<?=e($sc[0])?>">
    <?php if(!empty($sc[3])): ?><span class="count-badge" style="position:absolute;top:8px;right:10px;min-width:22px;height:22px;padding:0 7px;border-radius:999px;background:#dc2626;color:#fff;font-size:12px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;box-shadow:0 4px 10px rgba(220,38,38,.45);line-height:1;z-index:2"><?=(int)$sc[3]?></span><?php endif; ?>
    <span class="ic"><?=$sc[1]?></span>
    <span class="lb"><?=e($sc[2])?></span>
  </a>
<?php endforeach; ?>
</div>

<h2 style="margin:18px 0 12px">📌 আজকের সারাংশ</h2>
<div class="grid g2">
<div class="stat"><div class="label">মোট কাস্টমার</div><div class="value"><?=$s['users']?></div></div>
<div class="stat"><div class="label">মোট রিচার্জ</div><div class="value"><?=money($s['total_recharge'])?></div></div>
<div class="stat"><div class="label">Revenue</div><div class="value"><?=money($s['revenue'])?></div></div>
<div class="stat"><div class="label">মোট অর্ডার</div><div class="value"><?=$s['orders']?></div></div>
<div class="stat"><div class="label">আজকের অর্ডার</div><div class="value"><?=$s['today_orders']?></div></div>
<div class="stat"><div class="label">Pending রিচার্জ</div><div class="value"><?=$s['pending_recharges']?></div></div>
</div>
<?php require __DIR__.'/_footer.php';
