<!DOCTYPE html>
<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>" dir="<?php echo e(app()->getLocale() == 'ar' ? 'rtl' : 'ltr'); ?>">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?php echo e(\App\Models\SystemSetting::get('app_name', 'Enterprise FMS')); ?> - <?php echo $__env->yieldContent('title', 'Dashboard'); ?></title>

    <!-- 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=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">

    <!-- Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <link rel="stylesheet" href="<?php echo e(asset('css/ai-chat.css')); ?>">

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

    <?php if(app()->getLocale() == 'ar'): ?>
        <?php echo app('Illuminate\Foundation\Vite')(['resources/css/rtl.scss', 'resources/js/app.js']); ?>
    <?php else: ?>
        <?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.scss', 'resources/js/app.js']); ?>
    <?php endif; ?>
    <?php echo $__env->yieldContent('styles'); ?>
</head>

<body>
    <div id="app">
        <!-- Sidebar -->
        <aside class="sidebar">
            <div class="logo">
                <i class="bi bi-cpu-fill"></i>
                <span><?php echo e(\App\Models\SystemSetting::get('app_name', 'FMS')); ?></span>
            </div>

            <nav class="mt-3">
                <a href="<?php echo e(url('/')); ?>" class="nav-link <?php echo e(Request::is('/') ? 'active' : ''); ?>">
                    <i class="bi bi-speedometer2"></i> <span><?php echo e(__('Dashboard')); ?></span>
                </a>
                
                <!-- AI Intelligence Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseIntelligence" aria-expanded="<?php echo e(Request::is('intelligence*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-stars me-2"></i><?php echo e(__('Production Intelligence')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('intelligence*') ? 'show' : ''); ?>" id="collapseIntelligence">
                        <a href="<?php echo e(route('intelligence.dashboard')); ?>" class="nav-link sub-link <?php echo e(Request::is('intelligence') ? 'active' : ''); ?>">
                            <i class="bi bi-grid-1x2"></i> <span><?php echo e(__('Executive View')); ?></span>
                        </a>
                        <a href="<?php echo e(route('intelligence.risks')); ?>" class="nav-link sub-link <?php echo e(Request::is('intelligence/risks*') ? 'active' : ''); ?>">
                            <i class="bi bi-exclamation-triangle"></i> <span><?php echo e(__('Risk Monitor')); ?></span>
                        </a>
                        <a href="<?php echo e(route('intelligence.machines')); ?>" class="nav-link sub-link <?php echo e(Request::is('intelligence/machines*') ? 'active' : ''); ?>">
                            <i class="bi bi-gear-wide"></i> <span><?php echo e(__('Asset Health')); ?></span>
                        </a>
                        <a href="<?php echo e(route('intelligence.forecast')); ?>" class="nav-link sub-link <?php echo e(Request::is('intelligence/forecast*') ? 'active' : ''); ?>">
                            <i class="bi bi-graph-up"></i> <span><?php echo e(__('Supply Forecast')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Reporting Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseReporting" aria-expanded="<?php echo e(Request::is('reports*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-bar-chart-fill me-2 opacity-75"></i><?php echo e(__('Enterprise Reporting')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('reports*') ? 'show' : ''); ?>" id="collapseReporting">
                        <a href="<?php echo e(route('reports.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('reports') ? 'active' : ''); ?>">
                            <i class="bi bi-bar-chart-line"></i> <span><?php echo e(__('Report Center')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Structure Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseStructure" aria-expanded="<?php echo e(Request::is('companies*') || Request::is('factories*') || Request::is('branches*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-diagram-3-fill me-2 opacity-75"></i><?php echo e(__('Enterprise Structure')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('companies*') || Request::is('factories*') || Request::is('branches*') ? 'show' : ''); ?>" id="collapseStructure">
                        <a href="<?php echo e(route('companies.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('companies*') ? 'active' : ''); ?>">
                            <i class="bi bi-buildings"></i> <span><?php echo e(__('Companies')); ?></span>
                        </a>
                        <a href="<?php echo e(route('factories.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('factories*') ? 'active' : ''); ?>">
                            <i class="bi bi-building-gear"></i> <span><?php echo e(__('Factories')); ?></span>
                        </a>
                        <a href="<?php echo e(route('branches.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('branches*') ? 'active' : ''); ?>">
                            <i class="bi bi-geo"></i> <span><?php echo e(__('Branches')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Assets Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseAssets" aria-expanded="<?php echo e(Request::is('machines*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-gear-wide-connected me-2 opacity-75"></i><?php echo e(__('Assets & Equipment')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('machines*') ? 'show' : ''); ?>" id="collapseAssets">
                        <a href="<?php echo e(route('machines.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('machines*') ? 'active' : ''); ?>">
                            <i class="bi bi-gear-wide-connected"></i> <span><?php echo e(__('Machines')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Production Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseProduction" aria-expanded="<?php echo e(Request::is('products*') || Request::is('boms*') || Request::is('work-orders*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-pc-display-horizontal me-2 opacity-75"></i><?php echo e(__('Production Management')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('products*') || Request::is('boms*') || Request::is('work-orders*') || Request::is('raw-materials*') ? 'show' : ''); ?>" id="collapseProduction">
                        <a href="<?php echo e(route('raw-materials.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('raw-materials*') ? 'active' : ''); ?>">
                            <i class="bi bi-moisture"></i> <span><?php echo e(__('Raw Materials')); ?></span>
                        </a>
                        <a href="<?php echo e(route('products.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('products*') ? 'active' : ''); ?>">
                            <i class="bi bi-box-seam"></i> <span><?php echo e(__('Product Catalog')); ?></span>
                        </a>
                        <a href="<?php echo e(route('boms.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('boms*') ? 'active' : ''); ?>">
                            <i class="bi bi-diagram-3"></i> <span><?php echo e(__('Bill Of Materials')); ?></span>
                        </a>
                        <a href="<?php echo e(route('work-orders.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('work-orders*') ? 'active' : ''); ?>">
                            <i class="bi bi-file-earmark-check"></i> <span><?php echo e(__('Work Orders')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Inventory Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseInventory" aria-expanded="<?php echo e(Request::is('inventory*') || Request::is('warehouses*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-boxes me-2 opacity-75"></i><?php echo e(__('Inventory & Logistics')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('inventory*') || Request::is('warehouses*') ? 'show' : ''); ?>" id="collapseInventory">
                        <a href="<?php echo e(route('inventory.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('inventory') ? 'active' : ''); ?>">
                            <i class="bi bi-boxes"></i> <span><?php echo e(__('Global Stock')); ?></span>
                        </a>
                        <a href="<?php echo e(route('warehouses.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('warehouses*') ? 'active' : ''); ?>">
                            <i class="bi bi-house-door"></i> <span><?php echo e(__('Warehouses')); ?></span>
                        </a>
                        <a href="<?php echo e(route('inventory.movements')); ?>" class="nav-link sub-link <?php echo e(Request::is('inventory/movements*') ? 'active' : ''); ?>">
                            <i class="bi bi-clock-history"></i> <span><?php echo e(__('Stock Logs')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Supply Chain Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseSupply" aria-expanded="<?php echo e(Request::is('partners*') || Request::is('purchase-orders*') || Request::is('sales-orders*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-truck me-2 opacity-75"></i><?php echo e(__('Supply Chain & Sales')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('partners*') || Request::is('purchase-orders*') || Request::is('sales-orders*') ? 'show' : ''); ?>" id="collapseSupply">
                        <a href="<?php echo e(route('partners.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('partners*') ? 'active' : ''); ?>">
                            <i class="bi bi-people"></i> <span><?php echo e(__('Partner Directory')); ?></span>
                        </a>
                        <a href="<?php echo e(route('purchase-orders.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('purchase-orders*') ? 'active' : ''); ?>">
                            <i class="bi bi-cart"></i> <span><?php echo e(__('Purchase Orders')); ?></span>
                        </a>
                        <a href="<?php echo e(route('sales-orders.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('sales-orders*') ? 'active' : ''); ?>">
                            <i class="bi bi-graph-up-arrow"></i> <span><?php echo e(__('Sales Orders')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Fleet Management Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseFleet" aria-expanded="<?php echo e(Request::is('fleet*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-truck-flatbed me-2 opacity-75"></i><?php echo e(__('Fleet Management')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('fleet*') ? 'show' : ''); ?>" id="collapseFleet">
                        <a href="<?php echo e(route('fleet.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('fleet') ? 'active' : ''); ?>">
                            <i class="bi bi-card-checklist"></i> <span><?php echo e(__('Fleet Registry')); ?></span>
                        </a>
                        <a href="<?php echo e(route('fleet.loading.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('fleet-loading*') ? 'active' : ''); ?>">
                            <i class="bi bi-box-arrow-in-down"></i> <span><?php echo e(__('Fleet Loading')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- Quality Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseQuality" aria-expanded="<?php echo e(Request::is('quality-checks*') || Request::is('maintenance*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-shield-check me-2 opacity-75"></i><?php echo e(__('Quality & Maintenance')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('quality-checks*') || Request::is('maintenance*') ? 'show' : ''); ?>" id="collapseQuality">
                        <a href="<?php echo e(route('quality-checks.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('quality-checks*') ? 'active' : ''); ?>">
                            <i class="bi bi-shield-check"></i> <span><?php echo e(__('Quality Control')); ?></span>
                        </a>
                        <a href="<?php echo e(route('maintenance.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('maintenance*') ? 'active' : ''); ?>">
                            <i class="bi bi-tools"></i> <span><?php echo e(__('Machine CMMS')); ?></span>
                        </a>
                    </div>
                </div>

                <!-- System Section -->
                <div class="nav-section">
                    <button class="nav-section-label border-0 bg-transparent" 
                        data-bs-toggle="collapse" data-bs-target="#collapseSystem" aria-expanded="<?php echo e(Request::is('hr*') || Request::is('analytics*') || Request::is('settings*') ? 'true' : 'false'); ?>">
                        <span><i class="bi bi-sliders2 me-2 opacity-75"></i><?php echo e(__('System Settings')); ?></span>
                        <i class="bi bi-chevron-down chevron"></i>
                    </button>
                    <div class="collapse <?php echo e(Request::is('hr*') || Request::is('analytics*') || Request::is('settings*') ? 'show' : ''); ?>" id="collapseSystem">
                        <a href="<?php echo e(route('settings.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('settings*') ? 'active' : ''); ?>">
                            <i class="bi bi-sliders"></i> <span><?php echo e(__('General Settings')); ?></span>
                        </a>
                        <a href="<?php echo e(route('analytics.index')); ?>" class="nav-link sub-link <?php echo e(Request::is('analytics*') ? 'active' : ''); ?>">
                            <i class="bi bi-graph-up-arrow"></i> <span><?php echo e(__('Analytics Engine')); ?></span>
                        </a>
                    </div>
                </div>
            </nav>
        </aside>

        <!-- Main Wrapper -->
        <main class="main-wrapper">
            <!-- Header -->
            <header class="top-header">
                <div class="d-flex align-items-center gap-3">
                    <button class="btn btn-light d-lg-none"><i class="bi bi-list"></i></button>
                    <div class="search-box">
                        <div class="input-group">
                            <span class="input-group-text bg-light border-0"><i class="bi bi-search"></i></span>
                            <input type="text" class="form-control bg-light border-0" placeholder="<?php echo e(__('Search...')); ?>">
                        </div>
                    </div>
                </div>

                <div class="d-flex align-items-center gap-3">
                    <?php if(session('success')): ?>
                        <div class="alert alert-success py-1 px-3 mb-0 small"><?php echo e(session('success')); ?></div>
                    <?php endif; ?>

                    <!-- Custom Language Toggle -->
                    <div class="lang-switcher">
                        <a href="<?php echo e(route('lang.switch', 'en')); ?>" class="lang-label <?php echo e(app()->getLocale() == 'en' ? 'active' : ''); ?>">EN</a>
                        <a href="<?php echo e(route('lang.switch', app()->getLocale() == 'en' ? 'ar' : 'en')); ?>" class="lang-toggle-track <?php echo e(app()->getLocale()); ?>">
                            <div class="lang-toggle-thumb"></div>
                        </a>
                        <a href="<?php echo e(route('lang.switch', 'ar')); ?>" class="lang-label <?php echo e(app()->getLocale() == 'ar' ? 'active' : ''); ?>">AR</a>
                    </div>

                    <div class="dropdown">
                        <div class="user-profile d-flex align-items-center gap-2 cursor-pointer" 
                             data-bs-toggle="dropdown" aria-expanded="false" style="cursor: pointer;">
                            <div class="text-end d-none d-sm-block">
                                <h6 class="mb-0 small fw-bold"><?php echo e(Auth::check() ? Auth::user()->name : 'Guest Account'); ?></h6>
                                <span class="text-muted small opacity-75">Global Manager</span>
                            </div>
                            <img src="https://ui-avatars.com/api/?name=<?php echo e(Auth::check() ? urlencode(Auth::user()->name) : 'Guest'); ?>&background=3b82f6&color=fff&size=128"
                                class="rounded-circle shadow-sm border border-2 border-white" width="40" height="40">
                        </div>
                        <ul class="dropdown-menu dropdown-menu-end border-0 shadow-lg rounded-4 p-2 mt-3" style="min-width: 200px;">
                            <li>
                                <a class="dropdown-item py-2 rounded-3 d-flex align-items-center gap-2" href="<?php echo e(route('profile.index')); ?>">
                                    <i class="bi bi-person-circle fs-5 text-primary"></i>
                                    <span><?php echo e(__('My Profile')); ?></span>
                                </a>
                            </li>
                            <li><hr class="dropdown-divider opacity-50"></li>
                            <li>
                                <form action="<?php echo e(route('logout')); ?>" method="POST">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="dropdown-item py-2 rounded-3 d-flex align-items-center gap-2 text-danger">
                                        <i class="bi bi-box-arrow-right fs-5"></i>
                                        <span><?php echo e(__('Sign Out')); ?></span>
                                    </button>
                                </form>
                            </li>
                        </ul>
                    </div>
                </div>
            </header>

            <!-- Page Content -->
            <div class="container-fluid p-4">
                <?php echo $__env->yieldContent('content'); ?>
            </div>
        </main>
    </div>

    <!-- AI Agent Chat Bubble -->
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('access ai agent')): ?>
    <div class="ai-chat-wrapper">
        <div class="ai-chat-bubble" id="aiChatBubble">
            <i class="bi bi-stars"></i>
        </div>
        <div class="ai-chat-window" id="aiChatWindow">
            <div class="ai-chat-header">
                <div>
                    <h6 class="mb-0 fw-bold"><i class="bi bi-robot me-2"></i><?php echo e(__('AI Knowledge Agent')); ?></h6>
                    <small class="opacity-75"><?php echo e(__('Online & Learning')); ?></small>
                </div>
                <button type="button" class="btn-close btn-close-white" id="aiChatClose" aria-label="Close"></button>
            </div>
            <div class="ai-chat-messages" id="aiChatMessages">
                <div class="message message-ai">
                    <?php echo e(__("Hello! I am your AI Production Assistant. I'm trained on your live factory data. How can I help you today?")); ?>

                </div>
            </div>
            <div class="ai-chat-input-area">
                <div class="ai-chat-input-group">
                    <input type="text" id="aiChatInput" class="ai-chat-input" placeholder="<?php echo e(__('Ask about stocks, BOMs, movements...')); ?>">
                    <button class="btn btn-primary btn-sm rounded-circle p-2" id="aiChatSend">
                        <i class="bi bi-send-fill"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>
    <script src="<?php echo e(asset('js/ai-chat.js')); ?>"></script>
    <?php endif; ?>

    <!-- Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <?php echo $__env->yieldContent('scripts'); ?>
</body>

</html><?php /**PATH D:\laragon\www\production\resources\views/layouts/app.blade.php ENDPATH**/ ?>