<!DOCTYPE html>

<html lang="en" class="light-style layout-menu-fixed" dir="ltr" data-theme="theme-default"
    data-assets-path="<?php echo e(asset('assets')); ?>/" data-template="vertical-menu-template-free">

<head>
    <meta charset="utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />

    <title>bali arcade</title>

    <meta name="description" content="" />
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="<?php echo e(asset('assets/img/favicon/favicon.ico')); ?>" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
        href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
        rel="stylesheet" />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="<?php echo e(asset('assets/vendor/fonts/boxicons.css')); ?>" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="<?php echo e(asset('assets/vendor/css/core.css')); ?>" class="template-customizer-core-css" />
    <link rel="stylesheet" href="<?php echo e(asset('assets/vendor/css/theme-default.css')); ?>"
        class="template-customizer-theme-css" />
    <link rel="stylesheet" href="<?php echo e(asset('assets/css/demo.css')); ?>" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="<?php echo e(asset('assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css')); ?>" />

    <link rel="stylesheet" href="<?php echo e(asset('assets/vendor/libs/apex-charts/apex-charts.css')); ?>" />

    <!-- Page CSS -->
    
    <?php echo $__env->yieldPushContent('backend_css'); ?>
    <!-- Helpers -->
    <script src="<?php echo e(asset('assets/vendor/js/helpers.js')); ?>"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="<?php echo e(asset('assets/js/config.js')); ?>"></script>
</head>

<body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
        <div class="layout-container">
            <!-- Menu -->

            <aside id="layout-menu" class="layout-menu menu-vertical menu bg-menu-theme">
                <div class="app-brand demo mb-1">
                    <a href="<?php echo e(route('storefront.home')); ?>" class="app-brand-link">
                        
                        <img style="filter: invert(0%);" style="width: 100%"
                            src="<?php echo e(asset('assets/img/bali_logo.png')); ?>" alt="">
                    </a>


                    <a href="javascript:void(0);"
                        class="layout-menu-toggle menu-link text-large ms-auto d-block d-xl-none">
                        <i class="bx bx-chevron-left bx-sm align-middle"></i>
                    </a>
                </div>

                <div class="menu-inner-shadow"></div>

                <ul class="menu-inner py-1">
                    <!-- Dashboard -->
                    <li class="menu-item <?php echo e(request()->routeIs('admin.dashboard') ? 'active' : ''); ?>">
                        <a href="<?php echo e(route('admin.dashboard')); ?>" class="menu-link">
                            <i class="menu-icon tf-icons bx bx-home-circle"></i>
                            <div data-i18n="Analytics">Dashboard</div>
                        </a>
                    </li>

                    <?php if(auth()->user()->hasRole('super-admin')): ?>
                        <!-- Layouts -->
                        

                        
                        <li class="menu-item <?php echo e(request()->routeIs('admin.roles-permissions*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.roles-permissions.index')); ?>" class="menu-link">

                                <i class="menu-icon tf-icons bx bx-user"></i>
                                <div data-i18n="Analytics">Roles & Permissions</div>
                            </a>
                        </li>
                    <?php endif; ?>

                    
                    <?php if(auth()->user()->hasRole('super-admin') ||
                            auth()->user()->shops()->exists() ||
                            auth()->user()->createdShops()->exists()): ?>
                        <li
                            class="menu-item <?php echo e(request()->routeIs('admin.shops*') && !request()->routeIs('admin.shops.products*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.shops.index')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-store"></i>
                                <div data-i18n="Shops"> Shop Management</div>
                            </a>
                        </li>
                    <?php endif; ?>

                    <?php if(auth()->user()->hasRole('super-admin') || auth()->user()->createdFoodCarts()->exists()): ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.food-carts*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.food-carts.index')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-restaurant"></i>
                                <div data-i18n="Food Carts">Food Carts</div>
                            </a>
                        </li>
                    <?php endif; ?>

                    <?php if(auth()->user()->hasRole('super-admin')): ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.staff-assignment*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.staff-assignment.index')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-user-plus"></i>
                                <div data-i18n="Shop Staff Assignment">Shop Staff Assignment</div>
                            </a>
                        </li>
                    <?php endif; ?>

                    
                    <?php if(
                        !auth()->user()->hasRole('super-admin') &&
                            (auth()->user()->shops()->exists() || auth()->user()->createdShops()->exists())): ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.shops.products*') ? 'active' : ''); ?>">
                            <a href="javascript:void(0);" class="menu-link menu-toggle">
                                <i class="menu-icon tf-icons bx bx-package"></i>
                                <div data-i18n="Products">Products</div>
                            </a>

                            <ul class="menu-sub">
                                <?php
                                    $menuUser = auth()->user();
                                    $menuShops = \App\Models\Shop::query()
                                        ->select('id', 'name', 'slug', 'created_at')
                                        ->where('created_by', $menuUser->id)
                                        ->orWhereHas('users', function ($q) use ($menuUser) {
                                            $q->where('users.id', $menuUser->id);
                                        })
                                        ->latest('created_at')
                                        ->get();
                                ?>
                                <?php $__empty_1 = true; $__currentLoopData = $menuShops; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shop): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <li class="menu-item">
                                        <a href="<?php echo e(route('admin.shops.products.index', $shop)); ?>" class="menu-link">
                                            <div data-i18n="products"><?php echo e($shop->name); ?></div>
                                        </a>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <?php endif; ?>
                            </ul>
                        </li>
                    <?php endif; ?>

                    <?php if(auth()->user()->hasRole('super-admin')): ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.reels*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.reels.index')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-video"></i>
                                <div data-i18n="Reels">Reels</div>
                            </a>
                        </li>
                    <?php endif; ?>

                    <?php if(auth()->user()->hasRole('super-admin') ||
                            auth()->user()->shops()->exists() ||
                            auth()->user()->createdShops()->exists()): ?>
                        <?php
                            $menuUser = auth()->user();
                            $menuAccessibleShopIds = \App\Models\Shop::query()
                                ->where('created_by', $menuUser?->id)
                                ->orWhereHas('users', function ($q) use ($menuUser) {
                                    $q->where('users.id', $menuUser?->id);
                                })
                                ->pluck('id');
                            $menuAccessibleShopNames = \App\Models\Shop::query()
                                ->whereIn('id', $menuAccessibleShopIds)
                                ->pluck('name');
                            $newOrderCount = $menuUser?->hasRole('super-admin')
                                ? \App\Models\Order::query()->where('status', 'pending')->count()
                                : \App\Models\Order::query()
                                    ->where('status', 'pending')
                                    ->whereHas('items', function ($q) use (
                                        $menuAccessibleShopIds,
                                        $menuAccessibleShopNames,
                                    ) {
                                        $q->whereHas('product', function ($productQuery) use ($menuAccessibleShopIds) {
                                            $productQuery->whereIn('shop_id', $menuAccessibleShopIds);
                                        })->orWhereIn('shop_name', $menuAccessibleShopNames);
                                    })
                                    ->count();
                        ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.orders*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.orders.index')); ?>" class="menu-link"
                                data-pending-count-url="<?php echo e(route('admin.orders.pending-count')); ?>">
                                <i class="menu-icon tf-icons bx bx-package"></i>
                                <div data-i18n="Orders" class="d-flex align-items-center gap-2">
                                    <span>Orders</span>
                                    <span id="pendingOrderBadge"
                                        class="badge bg-danger rounded-pill <?php echo e($newOrderCount > 0 ? '' : 'd-none'); ?>"><?php echo e($newOrderCount); ?></span>
                                </div>
                            </a>
                        </li>
                    <?php endif; ?>

                    <?php if(auth()->user()->hasRole('super-admin')): ?>
                        <li class="menu-item <?php echo e(request()->routeIs('admin.contact-messages*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.contact-messages.index')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-message-dots"></i>
                                <div data-i18n="Contact Messages">Contact Messages </div>
                            </a>
                        </li>

                        <li class="menu-item <?php echo e(request()->routeIs('admin.contact-settings*') ? 'active' : ''); ?>">
                            <a href="<?php echo e(route('admin.contact-settings.edit')); ?>" class="menu-link">
                                <i class="menu-icon tf-icons bx bx-cog"></i>
                                <div data-i18n="Contact Settings">Contact Settings</div>
                            </a>
                        </li>
                    <?php endif; ?>




                    <li class="menu-item">
                        <a style="color:red;" href="#" class="menu-link" onclick="logoutConfirm(event)">
                            <i class="menu-icon tf-icons bx bx-log-out"></i>
                            <div>Logout</div>
                        </a>
                    </li>

                    <form id="logout-form" action="<?php echo e(route('logout')); ?>" method="POST" class="d-none">
                        <?php echo csrf_field(); ?>
                    </form>
                </ul>
            </aside>
            <!-- / Menu -->

            <!-- Layout container -->
            <div class="layout-page">
                <!-- Navbar -->



                <!-- / Navbar -->

                <!-- Content wrapper -->
                <div class="content-wrapper">
                    <div class="container ">
                        <div class="mt-4 bg-white px-2 py-5 rounded shadow-sm">



                            <div id="appToaster" class="toast-container position-fixed top-0 end-0 p-3"
                                style="z-index: 1080;"></div>


                            <?php echo $__env->yieldContent('backend_content'); ?>

                        </div>
                    </div>
                </div>
                <!-- / Content -->



                <div class="content-backdrop fade"></div>
            </div>
            <!-- Content wrapper -->
        </div>
        <!-- / Layout page -->
    </div>

    <!-- Overlay -->
    <div class="layout-overlay layout-menu-toggle"></div>
    </div>
    <!-- / Layout wrapper -->



    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="<?php echo e(asset('assets/vendor/libs/jquery/jquery.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/vendor/libs/popper/popper.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/vendor/js/bootstrap.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js')); ?>"></script>

    <script src="<?php echo e(asset('assets/vendor/js/menu.js')); ?>"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="<?php echo e(asset('assets/vendor/libs/apex-charts/apexcharts.js')); ?>"></script>

    <!-- Main JS -->
    <script src="<?php echo e(asset('assets/js/main.js')); ?>"></script>

    <!-- Page JS -->
    <script src="<?php echo e(asset('assets/js/dashboards-analytics.js')); ?>"></script>

    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>


    
    <script>
        window.appToast = function(message, type = 'success') {
            const toaster = document.getElementById('appToaster');
            if (!toaster || !message) return;

            const bgClass = type === 'error' ? 'text-bg-danger' : 'text-bg-success';
            const toastEl = document.createElement('div');
            toastEl.className = `toast align-items-center border-0 ${bgClass}`;
            toastEl.role = 'status';
            toastEl.ariaLive = 'polite';
            toastEl.ariaAtomic = 'true';
            toastEl.innerHTML = `
                <div class="d-flex">
                    <div class="toast-body">${message}</div>
                    <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
                </div>
            `;

            toaster.appendChild(toastEl);
            const bsToast = new bootstrap.Toast(toastEl, {
                delay: 3200
            });
            bsToast.show();
            toastEl.addEventListener('hidden.bs.toast', () => toastEl.remove());
        };

        <?php if(session('success')): ?>
            window.appToast(<?php echo json_encode(session('success'), 15, 512) ?>, 'success');
        <?php endif; ?>

        <?php if(session('error')): ?>
            window.appToast(<?php echo json_encode(session('error'), 15, 512) ?>, 'error');
        <?php endif; ?>


        function logoutConfirm(event) {
            event.preventDefault();

            Swal.fire({
                title: 'Logout?',
                text: "You will be signed out of your account.",
                icon: 'question',
                showCancelButton: true,
                confirmButtonText: 'Yes, Logout',
                cancelButtonText: 'Cancel',
                reverseButtons: true,
                focusCancel: true,
                customClass: {
                    popup: 'rounded-4 shadow',
                    confirmButton: 'btn btn-danger',
                    cancelButton: 'btn btn-secondary me-2'
                },
                buttonsStyling: false
            }).then((result) => {
                if (result.isConfirmed) {

                    // Optional loading state
                    Swal.fire({
                        title: 'Logging out...',
                        allowOutsideClick: false,
                        didOpen: () => {
                            Swal.showLoading();
                        }
                    });

                    document.getElementById('logout-form').submit();
                }
            });
        }

        // Live update pending-order badge in sidebar without page reload.
        (function initPendingOrderBadgePolling() {
            const ordersMenuLink = document.querySelector('[data-pending-count-url]');
            const badge = document.getElementById('pendingOrderBadge');
            if (!ordersMenuLink || !badge) return;

            const endpoint = ordersMenuLink.getAttribute('data-pending-count-url');
            if (!endpoint) return;

            const applyCount = (count) => {
                const numericCount = Number.isFinite(count) ? count : 0;
                badge.textContent = String(numericCount);
                badge.classList.toggle('d-none', numericCount <= 0);
            };

            const refreshPendingCount = async () => {
                try {
                    const res = await fetch(endpoint, {
                        headers: {
                            'Accept': 'application/json',
                        },
                        credentials: 'same-origin',
                    });

                    if (!res.ok) return;
                    const payload = await res.json();
                    applyCount(parseInt(payload?.pending_count ?? 0, 10));
                } catch (e) {
                    // Keep menu usable even if polling fails.
                }
            };

            refreshPendingCount();
            const pollId = setInterval(refreshPendingCount, 15000);

            document.addEventListener('visibilitychange', () => {
                if (document.visibilityState === 'visible') {
                    refreshPendingCount();
                }
            });

            window.addEventListener('beforeunload', () => clearInterval(pollId), {
                once: true
            });
        })();
    </script>
    <?php echo $__env->yieldPushContent('backend_js'); ?>
</body>

</html>
<?php /**PATH C:\Users\Abdur Rahman\Desktop\faa\resources\views/backend/layout.blade.php ENDPATH**/ ?>