<?php
header('Content-Type: application/json');

$coachId = $_GET['coach_id'] ?? null;
$date = $_GET['date'] ?? null;

if (!$coachId || !$date) {
    echo json_encode(['success' => false, 'message' => 'Missing parameters']);
    exit;
}

// Generate mock available time slots for the selected date
$slots = [];
$startHour = 9; // 9 AM
$endHour = 17;  // 5 PM

for ($hour = $startHour; $hour < $endHour; $hour++) {
    $startTime = sprintf('%02d:00', $hour);
    $endTime = sprintf('%02d:00', $hour + 1);
    $datetime = $date . ' ' . $startTime . ':00';
    
    // Skip lunch hour (12-1 PM)
    if ($hour == 12) continue;
    
    // Randomly make some slots unavailable (simulate real bookings)
    if (rand(1, 4) == 1) continue;
    
    $slots[] = [
        'datetime' => $datetime,
        'start_time' => date('g:i A', strtotime($startTime)),
        'end_time' => date('g:i A', strtotime($endTime))
    ];
}

echo json_encode([
    'success' => true,
    'available_slots' => $slots
]);
?>