<?php $user=Auth::user(); $dockPath=current_path(); $dockAlerts=unread_notification_count(); ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
    <meta name="robots" content="noindex,nofollow,noarchive,nosnippet">
    <meta name="theme-color" content="#030b18">
    <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="FleetLume">
    <title><?= e(page_title($pageTitle??null)) ?></title>
    <link rel="icon" href="<?= asset('images/favicon.ico') ?>" sizes="any">
    <link rel="icon" type="image/png" sizes="32x32" href="<?= asset('images/icon-32.png') ?>">
    <link rel="apple-touch-icon" sizes="180x180" href="<?= asset('images/icon-180.png') ?>">
    <link rel="manifest" href="<?= url('/manifest.json') ?>">
    <link rel="stylesheet" href="<?= asset('css/app.css') ?>">
    <link rel="stylesheet" href="<?= asset('css/app-v3.css') ?>?v=3.0.1">
    <link rel="stylesheet" href="<?= asset('css/app-v4.css') ?>?v=4.0.0">
    <link rel="stylesheet" href="<?= asset('css/app-v5.css') ?>?v=5.0.0">
    <link rel="stylesheet" href="<?= asset('css/app-v6.css') ?>?v=6.0.0">
</head>
<body class="role-<?= e($user['role']??'guest') ?> ui-v3 ui-v4 ui-v5 ui-v6" data-base-url="<?= e(rtrim(BASE_URL,'/')) ?>">
    <div class="app-shell">
        <?php require app_path('Views/partials/sidebar.php'); ?>
        <button class="sidebar-backdrop" type="button" data-sidebar-close aria-label="Close navigation"></button>
        <main class="main-content">
            <?php require app_path('Views/partials/topbar.php'); ?>
            <?php require app_path('Views/partials/flash.php'); ?>
            <section class="page-content"><?= $content ?></section>
        </main>
    </div>
    <nav class="mobile-dock" aria-label="Mobile shortcuts">
        <?php $dockRole=$user['role']??''; ?>
        <?php if($dockRole==='driver'): ?>
            <a class="<?= str_starts_with($dockPath,'/driver/loads')?'is-active':'' ?>" href="<?= url('/driver/loads') ?>"><?= nav_icon('loads') ?><span>Loads</span></a>
            <a class="<?= str_starts_with($dockPath,'/hos')?'is-active':'' ?>" href="<?= url('/hos/driver') ?>"><?= nav_icon('book') ?><span>HOS</span></a>
            <a class="<?= str_starts_with($dockPath,'/fuel')?'is-active':'' ?>" href="<?= url('/fuel') ?>"><?= nav_icon('fuel') ?><span>Fuel</span></a>
        <?php elseif($dockRole==='accountant'): ?>
            <a class="<?= $dockPath==='/accounting'?'is-active':'' ?>" href="<?= url('/accounting') ?>"><?= nav_icon('money') ?><span>Finance</span></a>
            <a class="<?= str_starts_with($dockPath,'/invoices')?'is-active':'' ?>" href="<?= url('/invoices') ?>"><?= nav_icon('invoice') ?><span>Invoices</span></a>
            <a class="<?= str_starts_with($dockPath,'/accounting/expenses')?'is-active':'' ?>" href="<?= url('/accounting/expenses') ?>"><?= nav_icon('doc') ?><span>Expenses</span></a>
        <?php elseif($dockRole==='maintenance'): ?>
            <a class="<?= str_starts_with($dockPath,'/maintenance')?'is-active':'' ?>" href="<?= url('/maintenance') ?>"><?= nav_icon('wrench') ?><span>Service</span></a>
            <a class="<?= str_starts_with($dockPath,'/trucks')?'is-active':'' ?>" href="<?= url('/trucks') ?>"><?= nav_icon('truck') ?><span>Trucks</span></a>
            <a class="<?= str_starts_with($dockPath,'/trailers')?'is-active':'' ?>" href="<?= url('/trailers') ?>"><?= nav_icon('trailer') ?><span>Trailers</span></a>
        <?php elseif($dockRole==='carrier'): ?>
            <a class="<?= $dockPath==='/carrier'?'is-active':'' ?>" href="<?= url('/carrier') ?>"><?= nav_icon('home') ?><span>Overview</span></a>
            <a class="<?= str_starts_with($dockPath,'/hos')?'is-active':'' ?>" href="<?= url('/hos') ?>"><?= nav_icon('book') ?><span>HOS</span></a>
            <a class="<?= str_starts_with($dockPath,'/documents')?'is-active':'' ?>" href="<?= url('/documents') ?>"><?= nav_icon('doc') ?><span>Docs</span></a>
        <?php elseif($dockRole==='team'): ?>
            <a class="<?= str_starts_with($dockPath,'/tasks')?'is-active':'' ?>" href="<?= url('/tasks') ?>"><?= nav_icon('task') ?><span>Tasks</span></a>
            <a class="<?= str_starts_with($dockPath,'/loads') && !str_starts_with($dockPath,'/loads/calendar')?'is-active':'' ?>" href="<?= url('/loads') ?>"><?= nav_icon('loads') ?><span>Loads</span></a>
            <a class="<?= str_starts_with($dockPath,'/loads/calendar')?'is-active':'' ?>" href="<?= url('/loads/calendar') ?>"><?= nav_icon('dispatch') ?><span>Schedule</span></a>
        <?php else: ?>
            <a class="<?= $dockPath==='/dashboard'?'is-active':'' ?>" href="<?= url('/dashboard') ?>"><?= nav_icon('home') ?><span>Dashboard</span></a>
            <a class="<?= str_starts_with($dockPath,'/loads')?'is-active':'' ?>" href="<?= url('/loads') ?>"><?= nav_icon('loads') ?><span>Loads</span></a>
            <a class="<?= str_starts_with($dockPath,'/tracking')?'is-active':'' ?>" href="<?= url('/tracking') ?>"><?= nav_icon('map') ?><span>Map</span></a>
        <?php endif; ?>
        <a class="dock-alert-link <?= str_starts_with($dockPath,'/notifications')?'is-active':'' ?>" href="<?= url('/notifications') ?>"><?= nav_icon('bell') ?><?php if($dockAlerts): ?><b><?= $dockAlerts>99?'99+':$dockAlerts ?></b><?php endif; ?><span>Alerts</span></a>
        <button type="button" data-mobile-menu><?= nav_icon('settings') ?><span>More</span></button>
    </nav>
    <div class="command-palette" data-command-palette hidden aria-hidden="true"><button class="command-backdrop" type="button" data-command-close aria-label="Close search"></button><section role="dialog" aria-modal="true" aria-label="Global search"><button class="command-close" type="button" data-command-close aria-label="Close search">&times;</button><div class="command-input"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg><form method="get" action="<?= url('/search') ?>"><input type="search" name="q" placeholder="Search loads, carriers, drivers, invoices…" autocomplete="off" data-command-input></form><kbd>Esc</kbd></div><div class="command-shortcuts"><span>Quick actions</span><a href="<?= url('/loads/create') ?>">Create load <kbd>L</kbd></a><?php if(can('ai.use')): ?><a href="<?= url('/ai/automation') ?>">Open AI Autopilot <kbd>A</kbd></a><?php endif; ?><a href="<?= url('/documents/create') ?>">Upload document <kbd>D</kbd></a><a href="<?= url('/fuel') ?>">Fuel allocation <kbd>F</kbd></a></div></section></div>
    <script src="<?= asset('js/app.js') ?>"></script>
    <script src="<?= asset('js/app-v3.js') ?>?v=3.0.1"></script>
    <script src="<?= asset('js/app-v4.js') ?>?v=4.0.0"></script>
    <script src="<?= asset('js/app-v5.js') ?>?v=5.0.0"></script>
    <script src="<?= asset('js/app-v6.js') ?>?v=6.0.0"></script>
</body>
</html>
