<?php
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/functions.php';

if (!is_admin_logged_in()) {
    redirect('login.php');
}

$admin_page_title = $page_title ?? 'Dashboard';
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?php echo $admin_page_title; ?> — Admin | SOL Christian Academy</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
  <link rel="stylesheet" href="css/admin.css">
  <link rel="icon" href="../assets/logo/sol-logo.png" type="image/png">
</head>
<body>

<nav class="admin-navbar">
  <div class="container-fluid d-flex justify-content-between align-items-center">
    <a href="index.php" class="admin-brand">
      <img src="../assets/logo/sol-logo-2.png" alt="SOL" style="height:32px;filter:brightness(0) invert(1);">
      <span>Admin Panel</span>
    </a>
    <div class="d-flex align-items-center gap-3">
      <a href="../index.php" class="text-white text-decoration-none" style="font-size:0.875rem;" target="_blank">View Site</a>
      <a href="logout.php" class="btn btn-sm btn-outline-light">Logout</a>
    </div>
  </div>
</nav>

<div class="admin-layout">
  <aside class="admin-sidebar">
    <a href="index.php" class="admin-nav-link <?php echo basename($_SERVER['SCRIPT_NAME']) === 'index.php' ? 'active' : ''; ?>">Dashboard</a>
    <a href="news.php" class="admin-nav-link <?php echo basename($_SERVER['SCRIPT_NAME']) === 'news.php' ? 'active' : ''; ?>">News</a>
    <a href="gallery.php" class="admin-nav-link <?php echo basename($_SERVER['SCRIPT_NAME']) === 'gallery.php' ? 'active' : ''; ?>">Gallery</a>
    <a href="testimonials.php" class="admin-nav-link <?php echo basename($_SERVER['SCRIPT_NAME']) === 'testimonials.php' ? 'active' : ''; ?>">Testimonials</a>
    <a href="messages.php" class="admin-nav-link <?php echo basename($_SERVER['SCRIPT_NAME']) === 'messages.php' ? 'active' : ''; ?>">Messages</a>
  </aside>
  <main class="admin-main">
