<?php
session_start();
require_once __DIR__ . '/../includes/db.php';

$user_id = $_SESSION['user_id'] ?? 0;

$stmt = $pdo->prepare("SELECT COUNT(*) AS unread FROM notifications WHERE user_id = ? AND is_read = 0");
$stmt->execute([$user_id]);

echo json_encode(["unread" => (int)$stmt->fetch(PDO::FETCH_ASSOC)['unread']]);
