<?php
/**
 * Top bar component — with search, notifications, and user profile.
 */
use App\Core\App;
$employee = App::getInstance()->currentEmployee();
$branch = App::getInstance()->currentBranch();
?>
<div class="topbar-right">
    <button class="topbar-btn sidebar-mobile-toggle" onclick="toggleSidebar()">
        <i data-lucide="menu" style="width:20px;height:20px;"></i>
    </button>
    <div class="topbar-search">
        <input type="text" id="global-search" placeholder="بحث سريع..." class="topbar-search-input" autocomplete="off">
    </div>
</div>
<div class="topbar-left">
    <span class="topbar-date"><?= arabic_date(today()) ?></span>
    <?php if ($branch): ?>
        <span class="topbar-branch">
            <i data-lucide="building-2" style="width:12px;height:12px;display:inline;vertical-align:middle;margin-left:4px;"></i>
            <?= e($branch['name_ar'] ?? '') ?>
        </span>
    <?php endif; ?>
    <div class="topbar-notifications">
        <button class="topbar-btn" id="notif-bell" title="الإشعارات">
            <i data-lucide="bell" style="width:20px;height:20px;"></i>
            <span class="notif-badge" id="notif-badge" style="display:none;">0</span>
        </button>
    </div>
    <?php if ($employee): ?>
        <div class="topbar-user">
            <span class="topbar-username"><?= e($employee->full_name_ar ?? ($employee['full_name_ar'] ?? 'مستخدم')) ?></span>
            <a href="/logout" class="topbar-btn topbar-logout" title="تسجيل الخروج">
                <i data-lucide="log-out" style="width:16px;height:16px;display:inline;vertical-align:middle;margin-left:4px;"></i>
                خروج
            </a>
        </div>
    <?php endif; ?>
</div>
