<?php
// admin/includes/header.php
if (!file_exists(__DIR__ . '/config.php')) {
    header("Location: install.php");
    exit;
}
require_once 'config.php';
require_once 'branding.php';
require_once 'migrations.php';
if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php') {
   redirect('login.php');
}
$selected_currency = $_GET['currency'] ?? $_SESSION['currency'] ?? DEFAULT_CURRENCY;
$_SESSION['currency'] = $selected_currency;
?>
<!DOCTYPE html>
<html class="dark" lang="en">
<head>
    <meta charset="utf-8"/>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <title><?= htmlspecialchars($page_title ?? 'Admin') ?> - <?= htmlspecialchars(getBrandName()) ?></title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"/>
    <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block" rel="stylesheet"/>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <?php
    $base_path = "";
    include 'includes/tailwind_config_include.php';
    ?>
    <link rel="stylesheet" href="includes/responsive.css">
    <!-- Firebase SDK (Compat) -->
    <script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-database-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging-compat.js"></script>
    <script src="includes/firebase_config.js"></script>
    <script src="includes/notification_manager.js"></script>
    <style>
        body {
            font-family: 'Inter', sans-serif;
            -webkit-tap-highlight-color: transparent;
        }
        .no-scrollbar::-webkit-scrollbar { display: none; }
        .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
        .material-symbols-outlined {
            font-family: 'Material Symbols Outlined' !important;
            font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
            font-weight: normal;
            font-style: normal;
            font-size: 24px;
            line-height: 1;
            letter-spacing: normal;
            text-transform: none;
            display: inline-block;
            white-space: nowrap;
            word-wrap: normal;
            direction: ltr;
            -webkit-font-feature-settings: 'liga';
            -webkit-font-smoothing: antialiased;
        }
        .fill-1 { font-variation-settings: 'FILL' 1; }
    </style>
</head>
<body class="bg-background-light dark:bg-background-dark text-slate-900 dark:text-white transition-colors duration-200">
<div class="fixed inset-0 bg-black/50 z-40 hidden" id="drawer-overlay"></div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    <?php if (isset($_SESSION['admin_id'])): ?>
    if (typeof NotificationManager !== 'undefined') {
        NotificationManager.init(<?= $_SESSION['admin_id'] ?>, 'admin');
    }
    <?php endif; ?>
});
</script>
