<?php
require_once __DIR__ . '/../../config/secure_bootstrap.php';
header('Content-Type: application/json; charset=utf-8');

try {
    $id = intval($_GET['id'] ?? 0);
    if ($id <= 0) {
        throw new Exception('ID tidak valid');
    }

    $stmt = $pdo->prepare("DELETE FROM audit_findings WHERE id = ?");
    $ok = $stmt->execute([$id]);

    echo json_encode([
        'success' => $ok,
        'message' => $ok ? 'Temuan berhasil dihapus' : 'Gagal menghapus temuan'
    ]);
} catch (Throwable $e) {
    echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}
