<!-- Super Admin Dashboard Content -->
<div class="space-y-6">

    <!-- Welcome Banner -->
    <div class="rounded-2xl p-6 flex items-center justify-between" style="background: linear-gradient(135deg, #4c1d95, #1d4ed8); border: 1px solid rgba(255,255,255,0.1)">
        <div>
            <h2 class="text-2xl font-bold text-white mb-1">Welcome back, <?php echo htmlspecialchars($_SESSION['name']); ?> 👑</h2>
            <p class="text-purple-200">Here's your SaaS platform overview for today.</p>
        </div>
        <div class="hidden md:block text-6xl opacity-20">🏢</div>
    </div>

    <!-- Stat Cards -->
    <div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
        <?php
        $cards = [
            ['label'=>'Total Restaurants','value'=>number_format($stats['total_restaurants']),'icon'=>'fa-store','color'=>'#8b5cf6','bg'=>'rgba(139,92,246,0.15)'],
            ['label'=>'Active Subscriptions','value'=>number_format($stats['active_subs']),'icon'=>'fa-credit-card','color'=>'#10b981','bg'=>'rgba(16,185,129,0.15)'],
            ['label'=>'Total Revenue','value'=>($_SESSION['currency'] ?? '$').number_format($stats['total_revenue'],2),'icon'=>'fa-dollar-sign','color'=>'#f59e0b','bg'=>'rgba(245,158,11,0.15)'],
            ['label'=>'Total Users','value'=>number_format($stats['total_users']),'icon'=>'fa-users','color'=>'#3b82f6','bg'=>'rgba(59,130,246,0.15)'],
        ];
        foreach($cards as $card): ?>
        <div class="stat-card p-5">
            <div class="flex justify-between items-start mb-4">
                <p class="text-slate-400 text-sm font-medium"><?php echo $card['label']; ?></p>
                <div class="w-10 h-10 rounded-xl flex items-center justify-center" style="background:<?php echo $card['bg']; ?>">
                    <i class="fas <?php echo $card['icon']; ?>" style="color:<?php echo $card['color']; ?>"></i>
                </div>
            </div>
            <p class="text-3xl font-bold text-white"><?php echo $card['value']; ?></p>
        </div>
        <?php endforeach; ?>
    </div>

    <!-- Recent Restaurants Table -->
    <div class="rounded-2xl overflow-hidden" style="background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08)">
        <div class="px-6 py-4 border-b border-white/5 flex justify-between items-center">
            <h3 class="font-semibold text-white">Recent Restaurants</h3>
            <a href="/restpo/superadmin/restaurants" class="text-sm text-purple-400 hover:text-purple-300">View All →</a>
        </div>
        <div class="overflow-x-auto">
            <table class="w-full text-sm">
                <thead><tr class="border-b border-white/5">
                    <th class="text-left px-6 py-3 text-slate-500 font-medium">Restaurant</th>
                    <th class="text-left px-6 py-3 text-slate-500 font-medium">Package</th>
                    <th class="text-left px-6 py-3 text-slate-500 font-medium">Status</th>
                    <th class="text-left px-6 py-3 text-slate-500 font-medium">Expires</th>
                </tr></thead>
                <tbody>
                    <?php if(empty($recent_restaurants)): ?>
                    <tr><td colspan="4" class="px-6 py-8 text-center text-slate-500">No restaurants yet. <a href="/restpo/superadmin/restaurants/create" class="text-purple-400 hover:underline">Add one →</a></td></tr>
                    <?php endif; ?>
                    <?php foreach($recent_restaurants as $r): ?>
                    <tr class="border-b border-white/5 hover:bg-white/5 transition">
                        <td class="px-6 py-4">
                            <div class="flex items-center gap-3">
                                <div class="w-9 h-9 rounded-lg flex items-center justify-center font-bold text-sm" style="background:rgba(139,92,246,0.2); color:#a78bfa"><?php echo strtoupper(substr($r['name'],0,2)); ?></div>
                                <div>
                                    <div class="font-medium text-white"><?php echo htmlspecialchars($r['name']); ?></div>
                                    <div class="text-slate-500 text-xs"><?php echo htmlspecialchars($r['email']); ?></div>
                                </div>
                            </div>
                        </td>
                        <td class="px-6 py-4 text-slate-400"><?php echo $r['package_name'] ?? 'None'; ?></td>
                        <td class="px-6 py-4">
                            <span class="px-2 py-1 rounded-full text-xs font-semibold" style="background:rgba(16,185,129,0.15); color:#6ee7b7"><?php echo $r['status']; ?></span>
                        </td>
                        <td class="px-6 py-4 text-slate-400"><?php echo $r['subscription_ends_at'] ? date('M d, Y', strtotime($r['subscription_ends_at'])) : '—'; ?></td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
