<?php declare(strict_types=1);
if (session_status() === PHP_SESSION_NONE) { session_start(); }
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/helpers.php';
$branchSelector = $ADMIN_BRANCH_SELECTOR_HTML ?? ''; // set in page
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>ELMS Admin</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
  <style>
    :root{
      --sidebar-bg:#0f172a; --sidebar-fg:#cbd5e1; --sidebar-fg-active:#fff; --accent:#4338ca;
      --tile1:#fce7f3; --tile2:#e9d5ff; --tile3:#ddd6fe; --tile4:#f5d0fe; --tile5:#e0e7ff; --tile6:#fee2e2;
    }
    body { background:#f5f6fb; }
    .admin-shell{min-height:100vh; display:flex;}
    .sidebar{width:240px; background:var(--sidebar-bg); color:var(--sidebar-fg);}
    .sidebar a{color:var(--sidebar-fg); text-decoration:none; display:block; padding:.55rem 1rem; border-left:3px solid transparent;}
    .sidebar a:hover{background:rgba(255,255,255,.06); color:var(--sidebar-fg-active);}
    .sidebar .brand{padding:.9rem 1rem; font-weight:600; color:#fff; border-bottom:1px solid rgba(255,255,255,.08);}
    .content{flex:1; display:flex; flex-direction:column; min-width:0;}
    .topbar{background:#111827; color:#e5e7eb; padding:.55rem 1rem;}
    .topbar .title{font-weight:600;}
    .tile{border-radius:.8rem; padding:1rem; display:flex; gap:.75rem; align-items:center; border:0; box-shadow:0 2px 6px rgba(0,0,0,.04);}
    .tile .num{width:36px; height:36px; display:flex; align-items:center; justify-content:center; border-radius:.6rem; font-weight:700;}
    .tile h6{margin:0; font-size:.95rem; color:#374151;}
    .kpi1{background:var(--tile6)} .kpi1 .num{background:#fecaca}
    .kpi2{background:var(--tile5)} .kpi2 .num{background:#c7d2fe}
    .kpi3{background:var(--tile3)} .kpi3 .num{background:#c4b5fd}
    .kpi4{background:var(--tile2)} .kpi4 .num{background:#e9d5ff}
    .kpi5{background:var(--tile4)} .kpi5 .num{background:#f5d0fe}
    .kpi6{background:var(--tile1)} .kpi6 .num{background:#fbcfe8}
    .card-soft{border:0; box-shadow:0 3px 14px rgba(0,0,0,.06); border-radius:1rem;}
    .btn-ghost{background:#fff; border:1px solid #e5e7eb;}
  </style>
</head>
<body>
<div class="admin-shell">
  <aside class="sidebar">
    <div class="brand">EDEN CAMPUS LEARNING<br>MANAGEMENT SYSTEMS 202</div>
    <a href="<?= BASE_URL ?>/admin/index.php"><i class="bi bi-house-door me-2"></i> Home</a>
    <div class="px-3 mt-3 text-uppercase small text-secondary">Manage Institute</div>
    <a href="#"><i class="bi bi-building me-2"></i> Centres</a>
    <a href="#"><i class="bi bi-people me-2"></i> Lecturers</a>
    <a href="#"><i class="bi bi-journal-text me-2"></i> Courses</a>
    <a href="#"><i class="bi bi-person-lines-fill me-2"></i> Students</a>
    <div class="px-3 mt-3 text-uppercase small text-secondary">Operations</div>
    <a href="<?= BASE_URL ?>/admin/batches/"><i class="bi bi-diagram-2 me-2"></i> Centre Batches</a>
    <a href="#"><i class="bi bi-shield-check me-2"></i> Verification</a>
    <a href="#"><i class="bi bi-chat-square-quote me-2"></i> Moderation</a>
    <a href="#"><i class="bi bi-graph-up me-2"></i> Reports</a>
  </aside>

  <div class="content">
    <header class="topbar d-flex align-items-center gap-3">
      <div class="title flex-grow-1">Summary View</div>
      <?= $branchSelector ?>
      <div>
        <span class="me-3 small">Admin</span>
        <a class="btn btn-sm btn-ghost" href="<?= BASE_URL ?>/auth/logout.php">Logout</a>
      </div>
    </header>

    <main class="p-3 p-lg-4">
