<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title><?php echo $__env->yieldContent('title','HIGHRA CRM'); ?></title>
    <link rel="stylesheet" href="/css/crm.css">
    <script>
        // Apply sidebar state immediately before render to prevent flickering
        if (localStorage.getItem('sidebar_collapsed') === 'true') {
            document.documentElement.classList.add('sidebar-collapsed');
        }
    </script>
</head>
<body class="<?php echo e((isset($_COOKIE['sidebar_collapsed']) && $_COOKIE['sidebar_collapsed'] == '1') ? 'sidebar-collapsed' : ''); ?>">
    <aside>
        <div class="brand-header">
            <div class="brand">
                <div class="brand-logo-icon">H</div>
                <span class="brand-text">HIGHRA CRM</span>
            </div>
            <button id="sidebarToggle" class="toggle-btn" title="Toggle Sidebar (Expand/Collapse)" aria-label="Toggle Sidebar">
                <svg id="toggleIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                    <polyline points="15 18 9 12 15 6"></polyline>
                </svg>
            </button>
        </div>

        <nav>
            <?php if(auth()->user()?->hasPermission('dashboard.view')): ?>
                <a href="/dashboard" class="<?php echo e(request()->is('dashboard') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/></svg>
                    <span class="nav-label">Dashboard</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('leads.view')): ?>
                <a href="/leads" class="<?php echo e(request()->is('leads*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
                    <span class="nav-label">Leads</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('pipeline.view')): ?>
                <a href="/pipeline" class="<?php echo e(request()->is('pipeline*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>
                    <span class="nav-label">Pipeline</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('customers.view')): ?>
                <a href="/customers" class="<?php echo e(request()->is('customers*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
                    <span class="nav-label">Customers</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('quotations.view')): ?>
                <a href="/quotations" class="<?php echo e(request()->is('quotations*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
                    <span class="nav-label">Quotations</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('leads.view')): ?>
                <a href="/followups" class="<?php echo e(request()->is('followups*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
                    <span class="nav-label">Follow-ups</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('users.view')): ?>
                <a href="/users" class="<?php echo e(request()->is('users*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="17" y1="11" x2="23" y2="11"/></svg>
                    <span class="nav-label">Users</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('roles.view')): ?>
                <a href="/roles" class="<?php echo e(request()->is('roles*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
                    <span class="nav-label">Roles & Permissions</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('audit_logs.view')): ?>
                <a href="/audit-logs" class="<?php echo e(request()->is('audit-logs*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
                    <span class="nav-label">Audit Logs</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('reports.view')): ?>
                <a href="/reports" class="<?php echo e(request()->is('reports*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>
                    <span class="nav-label">Reports</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('analytics.view')): ?>
                <a href="/analytics" class="<?php echo e(request()->is('analytics*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>
                    <span class="nav-label">Analytics</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('whatsapp.view')): ?>
                <a href="/whatsapp" class="<?php echo e(request()->is('whatsapp*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>
                    <span class="nav-label">WhatsApp</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('meta.view')): ?>
                <a href="/meta" class="<?php echo e(request()->is('meta*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><circle cx="12" cy="12" r="10"/><path d="M8 12a4 4 0 0 1 8 0"/></svg>
                    <span class="nav-label">Meta Integration</span>
                </a>
            <?php endif; ?>

            <?php if(auth()->user()?->hasPermission('settings.view')): ?>
                <a href="/settings" class="<?php echo e(request()->is('settings*') ? 'active' : ''); ?>">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
                    <span class="nav-label">Settings</span>
                </a>
            <?php endif; ?>
        </nav>

        <div class="sidebar-footer">
            <form method="post" action="/logout">
                <?php echo csrf_field(); ?>
                <button type="submit" class="logout-btn" title="Sign out of CRM">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
                    <span>Logout</span>
                </button>
            </form>
        </div>
    </aside>

    <main>
        <header>
            <div class="header-title"><?php echo $__env->yieldContent('header','Dashboard'); ?></div>
            <?php if(auth()->check()): ?>
            <div class="user-pill">Logged in as: <strong><?php echo e(auth()->user()->name); ?></strong> (<?php echo e(ucfirst(auth()->user()->role)); ?>)</div>
            <?php endif; ?>
        </header>
        <section>
            <?php if(session('success')): ?>
                <div class="ok"><?php echo e(session('success')); ?></div>
            <?php endif; ?>
            <?php if(session('error')): ?>
                <div class="err"><?php echo e(session('error')); ?></div>
            <?php endif; ?>
            <?php if(isset($errors) && $errors->any()): ?>
                <div class="err">
                    <ul style="margin:0;padding-left:18px">
                        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <li><?php echo e($error); ?></li>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </ul>
                </div>
            <?php endif; ?>
            <?php echo $__env->yieldContent('content'); ?>
        </section>
    </main>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const sidebarToggle = document.getElementById('sidebarToggle');
            const toggleIcon = document.getElementById('toggleIcon');
            
            function syncSidebarState() {
                const isCollapsed = document.body.classList.contains('sidebar-collapsed');
                if (isCollapsed) {
                    toggleIcon.innerHTML = '<polyline points="9 18 15 12 9 6"></polyline>';
                    localStorage.setItem('sidebar_collapsed', 'true');
                    document.cookie = "sidebar_collapsed=1; path=/; max-age=31536000";
                } else {
                    toggleIcon.innerHTML = '<polyline points="15 18 9 12 15 6"></polyline>';
                    localStorage.setItem('sidebar_collapsed', 'false');
                    document.cookie = "sidebar_collapsed=0; path=/; max-age=31536000";
                }
            }

            // Restore from localStorage
            if (localStorage.getItem('sidebar_collapsed') === 'true') {
                document.body.classList.add('sidebar-collapsed');
            } else if (localStorage.getItem('sidebar_collapsed') === 'false') {
                document.body.classList.remove('sidebar-collapsed');
            }
            syncSidebarState();

            if (sidebarToggle) {
                sidebarToggle.addEventListener('click', function(e) {
                    e.preventDefault();
                    document.body.classList.toggle('sidebar-collapsed');
                    syncSidebarState();
                });
            }
        });
    </script>
</body>
</html><?php /**PATH /Users/apple/Downloads/laravel/resources/views/layouts/app.blade.php ENDPATH**/ ?>