<?php
$stmt = $conn->query("SELECT school_name, school_logo, school_favicon FROM administratives LIMIT 1");
if ($stmt && $stmt->num_rows > 0) {
    $adminData = $stmt->fetch_assoc();
    $school_name    = $adminData['school_name'] ?? 'CBT Student Panel';
    $school_logo    = !empty($adminData['school_logo'])    ? $adminData['school_logo']    : null;
    $school_favicon = !empty($adminData['school_favicon']) ? $adminData['school_favicon'] : null;
}
?>
<?php
$student_name  = '';
$student_photo = '';

if (isset($_SESSION['student_id']) || isset($_SESSION['student'])) {
    $student_id = $_SESSION['student_id'] ?? $_SESSION['student'];
    $stmt = $conn->prepare("SELECT firstname, lastname, passport FROM students WHERE id = ? LIMIT 1");
    $stmt->bind_param("i", $student_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($result && $result->num_rows > 0) {
        $student     = $result->fetch_assoc();
        $student_name  = trim($student['firstname'] . ' ' . $student['lastname']);
        $student_photo = !empty($student['passport']) ? $student['passport'] : $student_photo;
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="<?= htmlspecialchars($school_name) ?> CBT Student Panel — Online Exam Portal">
  <title><?= htmlspecialchars($school_name) ?> - CBT Student Panel</title>

  <!-- Favicon & PWA -->
  <?php if (!empty($school_favicon)): ?>
    <link rel="icon" href="../../<?= htmlspecialchars($school_favicon) ?>" type="image/x-icon">
  <?php endif; ?>
  <link rel="manifest" href="../../manifest.json">
  <meta name="theme-color" content="#1a5c2a">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-title" content="EdumacFlo CBT">

  <!-- Google Fonts -->
  <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=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">

  <!-- AdminLTE & Icons -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">

  <!-- CBT Premium Theme (must be last to override) -->
  <link rel="stylesheet" href="../../assets/css/cbt-theme.css">

  <style>
    .content-wrapper {
      overflow-y: auto;
      max-height: calc(100vh - 114px);
    }
  </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
