<?php
// ============================================================
//  ajax/get_research_topics.php
// ============================================================
require_once __DIR__ . '/../config/db.php';
header('Content-Type: application/json');

$specialtyId = (int)($_GET['specialty_id'] ?? 0);
if (!$specialtyId) jsonResponse(false, 'Specialty ID required');

try {
    $stmt = db()->prepare(
        "SELECT * FROM research_topics WHERE specialty_id = ? AND is_active = 1 ORDER BY title"
    );
    $stmt->execute([$specialtyId]);
    jsonResponse(true, '', ['topics' => $stmt->fetchAll()]);
} catch (PDOException $e) {
    jsonResponse(false, 'DB error: ' . $e->getMessage());
}

