<?php
require_once __DIR__ . '/config/database.php';
$db = Database::getInstance();
$courseId = 1;
$row = $db->get('SELECT id, title, status, region, is_published, instructor_id, thumbnail, visibility FROM courses WHERE id = ?', array($courseId));
header('Content-Type: application/json');
if (!$row) {
    echo json_encode(['success' => false, 'message' => 'Course not found']);
    exit;
}
$thumbPath = __DIR__ . '/' . ltrim($row['thumbnail'] ?? '', '/');
$thumbExists = $row['thumbnail'] ? file_exists($thumbPath) : false;
$row['thumbnail_exists'] = $thumbExists;
echo json_encode(['success' => true, 'course' => $row], JSON_PRETTY_PRINT);
