<?php
/**
 * logout.php — Destroy session and redirect to login
 */
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/includes/audit.php';

// Log before destroying session
if (is_logged_in()) {
    audit_log('user.logout', 'User logged out', current_user_id(), 'user');
}

logout_user();
header('Location: login.php');
exit;
