<?php
// Get user info for header
$username = htmlspecialchars($_SESSION["username"] ?? 'Super Admin');
$photo = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="80" height="80"%3E%3Crect width="80" height="80" fill="%234f46e5"/%3E%3Ctext x="50%25" y="50%25" dominant-baseline="middle" text-anchor="middle" font-family="Arial, sans-serif" font-size="32" font-weight="bold" fill="white"%3ESA%3C/text%3E%3C/svg%3E';

if (isset($conn) && $conn instanceof mysqli) {
    $user_id = $_SESSION["id"];
    $sql = "SELECT photo FROM users WHERE id = ?";
    if ($stmt = $conn->prepare($sql)) {
        $stmt->bind_param("i", $user_id);
        if ($stmt->execute()) {
            $stmt->bind_result($photo_db);
            $stmt->fetch();
            if (!empty($photo_db)) {
                $photo = htmlspecialchars($photo_db);
            }
        }
        $stmt->close();
    }
}
?>
<!-- Header for Super Admin -->
<header class="header">
    <button class="menu-toggle" id="menuToggle">
        <i class="fas fa-bars"></i>
    </button>
    <div class="school-info">
        <img src="images/logo.png" alt="Divine Reports Logo">
        <h1>DIVINE REPORTS</h1>
    </div>
    <div class="header-right">
        <div class="search-bar">
            <i class="fas fa-search"></i>
            <input type="text" placeholder="Search..." id="searchPlaceholder">
        </div>
        <div class="notifications">
            <i class="fas fa-bell"></i>
            <span class="badge">0</span>
        </div>
        <div class="user-profile">
            <img src="<?php echo $photo; ?>" alt="User Photo">
            <div>
                <div class="user-name"><?php echo $username; ?></div>
                <div class="user-email">Super Admin</div>
            </div>
            <i class="fas fa-chevron-down"></i>
        </div>
    </div>
</header>