$(document).ready(function() {
    // Fetch dashboard data from server
    $.get('admin_dashboard_data.php', function(data) {
        const dashboardData = JSON.parse(data);
        
        // Update key metrics
        $('#studentCount').text(dashboardData.studentCount);
        $('#teacherCount').text(dashboardData.teacherCount);
        $('#totalIncome').text(`$${dashboardData.totalIncome}`);
        $('#totalExpenditure').text(`$${dashboardData.totalExpenditure}`);
        
        // Update notifications
        const notifications = dashboardData.notifications;
        notifications.forEach(notification => {
            $('#notifications ul').append(`<li class="list-group-item">${notification.message} - ${notification.created_at}</li>`);
        });

        // Update recent activities
        const recentActivities = dashboardData.recentActivities;
        recentActivities.forEach(activity => {
            $('#recentActivities ul').append(`<li class="list-group-item">${activity.description} - ${activity.date}</li>`);
        });
    });
});
