<?php
session_start();
include('../includes/config.php');

// Get stats
$cats_result = mysqli_query($conn, "SELECT COUNT(*) as total FROM faq_categories");
$cats_row = mysqli_fetch_assoc($cats_result);
$total_cats = $cats_row['total'];

$active_cats_result = mysqli_query($conn, "SELECT COUNT(*) as total FROM faq_categories WHERE is_active = 1");
$active_cats_row = mysqli_fetch_assoc($active_cats_result);
$active_cats = $active_cats_row['total'];

$faqs_result = mysqli_query($conn, "SELECT COUNT(*) as total FROM faq_items");
$faqs_row = mysqli_fetch_assoc($faqs_result);
$total_faqs = $faqs_row['total'];

$active_faqs_result = mysqli_query($conn, "SELECT COUNT(*) as total FROM faq_items WHERE is_active = 1");
$active_faqs_row = mysqli_fetch_assoc($active_faqs_result);
$active_faqs = $active_faqs_row['total'];

echo json_encode(array(
    'success' => true,
    'total_cats' => $total_cats,
    'active_cats' => $active_cats,
    'total_faqs' => $total_faqs,
    'active_faqs' => $active_faqs
));
?>