<?php
// Template Master Admin Header - Konsisten dengan admin-header.php
// File: master-admin-header.php

if (!defined('ADMIN_ACCESS')) {
    die('Direct access not allowed');
}

$currentPage = basename($_SERVER['PHP_SELF'], '.php');
$pageTitle = $pageTitle ?? 'Master Admin Panel';

// Check if admin is master
$isMasterAdmin = false;
if (isset($_SESSION['integrated_admin_data']['is_master']) && $_SESSION['integrated_admin_data']['is_master']) {
    $isMasterAdmin = true;
}
if (isset($_SESSION['integrated_admin_data']['admin_type']) && $_SESSION['integrated_admin_data']['admin_type'] === 'master') {
    $isMasterAdmin = true;
}

?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $pageTitle; ?> - <?php echo ADMIN_TITLE; ?></title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="../shared/css/admin-styles-fixed.css" rel="stylesheet">
</head>
<body>
    <!-- Admin Header -->
    <header class="admin-header">
        <div class="admin-logo">
            <i class="fas fa-shield-alt"></i>
            <div class="admin-title"><?php echo defined('ADMIN_TITLE') ? str_replace(' Admin Panel', '', ADMIN_TITLE) : 'MASTER ADMIN'; ?></div>
        </div>
        
        <nav class="nav-links">
            <a href="dashboard.php" class="<?php echo $currentPage === 'dashboard' ? 'active' : ''; ?>">
                <i class="fas fa-home"></i> Dashboard
            </a>
            
            <?php if ($isMasterAdmin): ?>
            <!-- Master Admin Menu -->
            <a href="master-multi-result-input.php" class="<?php echo $currentPage === 'master-multi-result-input' ? 'active' : ''; ?>">
                <i class="fas fa-plus-circle"></i> Multi Site Result Input
            </a>
            <a href="master-view-all-results.php" class="<?php echo $currentPage === 'master-view-all-results' ? 'active' : ''; ?>">
                <i class="fas fa-eye"></i> View All Results
            </a>
            <a href="master-buku-mimpi.php" class="<?php echo $currentPage === 'master-buku-mimpi' ? 'active' : ''; ?>">
                <i class="fas fa-moon"></i> Master Buku Mimpi
            </a>
            <a href="master-support.php" class="<?php echo $currentPage === 'master-support' ? 'active' : ''; ?>">
                <i class="fas fa-headset"></i> Support Tickets
            </a>
            <?php endif; ?>
            
            <!-- Additional Admin Menu -->
            <a href="settings.php" class="<?php echo $currentPage === 'settings' ? 'active' : ''; ?>">
                <i class="fas fa-cog"></i> Database Management
            </a>
            <a href="../index.php" target="_blank" class="website-link">
                <i class="fas fa-globe"></i> Website
            </a>
            <a href="logout.php" class="logout-btn">
                <i class="fas fa-sign-out-alt"></i> Logout
            </a>
        </nav>
    </header>

    <!-- Main Content Container -->
    <div class="container">
        <div class="page-header">
            <h1 class="page-title"><?php echo $pageTitle; ?></h1>
            <?php if (isset($pageDescription)): ?>
            <p class="page-subtitle"><?php echo $pageDescription; ?></p>
            <?php endif; ?>
        </div>