<?php
require __DIR__ . '/../Login/config.php';
if (session_status() === PHP_SESSION_NONE) session_start();
header('Content-Type: application/json');

if (empty($_SESSION['user_id'])) {
  echo json_encode(['status'=>'unauthorized']); exit;
}
$user_id = (int)$_SESSION['user_id'];

$stmt = $pdo->prepare("UPDATE notifications SET is_read = 1 WHERE user_id = :uid AND is_read = 0");
$stmt->execute([':uid'=>$user_id]);

echo json_encode(['status'=>'ok']);
