/home3/bmscom/jupiter.bms69.com/admin_dashboard.php
<?php
// admin_dashboard.php
require_once 'includes/db.php';
if (!isAdmin()) redirect('admin_login.php');

$today = date('Y-m-d');

// Fetch Today's Bookings
$today_stmt = $pdo->prepare("SELECT b.*, g.name as ground_name FROM bookings b JOIN grounds g ON b.ground_id = g.id WHERE b.booking_date = ? AND b.status = 'confirmed' ORDER BY b.start_time");
$today_stmt->execute([$today]);
$today_bookings = $today_stmt->fetchAll();

// Fetch Upcoming Bookings
$upcoming_stmt = $pdo->prepare("SELECT b.*, g.name as ground_name FROM bookings b JOIN grounds g ON b.ground_id = g.id WHERE b.booking_date > ? AND b.status = 'confirmed' ORDER BY b.booking_date, b.start_time LIMIT 10");
$upcoming_stmt->execute([$today]);
$upcoming_bookings = $upcoming_stmt->fetchAll();

require_once 'includes/header.php';
?>

<div class="space-y-10">
    <div class="flex flex-col md:flex-row md:items-center justify-between gap-6">
        <div>
            <h1 class="text-3xl font-black text-white">Management Dashboard</h1>
            <p class="text-slate-400 mt-1">Daily overview and upcoming schedule.</p>
        </div>
        <div class="flex gap-4">
            <a href="admin_slots.php" class="px-6 py-3 bg-slate-800 hover:bg-slate-700 text-white font-bold rounded-2xl transition-all border border-slate-700/50">Manage Slots</a>
            <a href="admin_finance.php" class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-2xl transition-all shadow-lg shadow-blue-500/20">Financials</a>
        </div>
    </div>

    <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
        <!-- Today's Column -->
        <div class="glass p-8 rounded-[2.5rem] shadow-2xl relative overflow-hidden">
             <div class="absolute -right-8 -top-8 w-32 h-32 bg-blue-600/10 rounded-full blur-3xl"></div>
             
             <h2 class="text-xl font-black text-white mb-8 flex items-center gap-3">
                <span class="w-1.5 h-6 bg-blue-600 rounded-full"></span>
                Active Today (<?php echo date('M d'); ?>)
             </h2>

             <div class="space-y-4">
                <?php if(empty($today_bookings)): ?>
                    <div class="py-20 text-center text-slate-500 italic">No bookings scheduled for today.</div>
                <?php else: ?>
                    <?php foreach($today_bookings as $b): ?>
                        <div class="bg-slate-900/50 border border-slate-800/80 p-6 rounded-2xl flex justify-between items-center group hover:border-blue-500/50 transition-colors">
                            <div>
                                <p class="text-lg font-black text-white"><?php echo $b['customer_name']; ?></p>
                                <p class="text-xs font-bold text-slate-500 uppercase tracking-widest mt-1"><?php echo $b['ground_name']; ?> • <?php echo $b['customer_phone']; ?></p>
                            </div>
                            <div class="text-right">
                                <p class="text-blue-500 font-black text-lg"><?php echo date('g:ia', strtotime($b['start_time'])); ?></p>
                                <span class="text-[10px] font-black text-green-500 uppercase tracking-widest bg-green-500/10 px-2 py-0.5 rounded">Confirmed</span>
                            </div>
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
             </div>
        </div>

        <!-- Upcoming Column -->
        <div class="glass p-8 rounded-[2.5rem] shadow-2xl">
             <h2 class="text-xl font-black text-white mb-8 flex items-center gap-3">
                <span class="w-1.5 h-6 bg-amber-500 rounded-full"></span>
                Upcoming Schedule
             </h2>

             <div class="space-y-4">
                <?php if(empty($upcoming_bookings)): ?>
                    <div class="py-20 text-center text-slate-500 italic">No upcoming bookings.</div>
                <?php else: ?>
                    <?php foreach($upcoming_bookings as $b): ?>
                        <div class="bg-slate-900/40 p-5 rounded-2xl flex justify-between items-center border border-slate-800/50">
                            <div>
                                <p class="text-white font-bold"><?php echo $b['customer_name']; ?></p>
                                <p class="text-xs font-medium text-slate-400"><?php echo date('D, M d', strtotime($b['booking_date'])); ?> @ <?php echo $b['ground_name']; ?></p>
                            </div>
                            <p class="text-slate-300 font-black text-sm"><?php echo date('g:ia', strtotime($b['start_time'])); ?></p>
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
             </div>
        </div>
    </div>
</div>

<?php require_once 'includes/footer.php'; ?>