<?php
require '../../app/db.php';
require '../includes/auth.php';

header('Content-Type: application/json');

$notifications = $pdo->query("
SELECT * FROM notifications
ORDER BY created_at DESC
LIMIT 10
")->fetchAll(PDO::FETCH_ASSOC);

$unread = $pdo->query("
SELECT COUNT(*) FROM notifications WHERE is_read=0
")->fetchColumn();

echo json_encode([
    'notifications' => $notifications,
    'unread' => $unread
]);
