<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <title>Prolex - Legal Practice Management</title>
    <link rel="icon" type="image/png" href="<?php echo e(asset('prolexlogo.png')); ?>">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <style>
        /* Enhanced Sky Blue Professional Theme */
        :root {
            --primary-blue: #0ea5e9;
            --sky-blue: #38bdf8;
            --light-blue: #7dd3fc;
            --dark-blue: #0284c7;
            --navy: #1e3a8a;
            --navy-dark: #1e293b;
            --accent-gold: #fbbf24;
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --text-light: #94a3b8;
            --bg-light: #f8fafc;
            --bg-white: #ffffff;
            --border-color: #e2e8f0;
            --shadow-sm: 0 1px 3px rgba(14, 165, 233, 0.08);
            --shadow-md: 0 4px 12px rgba(14, 165, 233, 0.12);
            --shadow-lg: 0 10px 30px rgba(14, 165, 233, 0.15);
            --shadow-xl: 0 20px 50px rgba(14, 165, 233, 0.2);
        }

        /* Dark Mode Variables */
        [data-bs-theme="dark"] {
            --primary-blue: #0ea5e9;
            --sky-blue: #38bdf8;
            --light-blue: #7dd3fc;
            --dark-blue: #0284c7;
            --navy: #1e3a8a;
            --navy-dark: #000000;
            --accent-gold: #fbbf24;
            --text-primary: #ffffff;
            --text-secondary: #cccccc;
            --text-light: #888888;
            --bg-light: #000000;
            --bg-white: #1a1a1a;
            --border-color: #444444;
            --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
            --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.6);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', sans-serif;
            line-height: 1.6;
            color: var(--text-primary);
            background: var(--bg-light);
            overflow-x: hidden;
        }

        /* Premium Sidebar with Enhanced Logo Space */
        .sidebar {
            width: 300px;
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
            background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
            color: white;
            overflow-y: auto;
            overflow-x: hidden;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            box-shadow: var(--shadow-xl);
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

        [data-bs-theme="dark"] .sidebar {
            background: linear-gradient(180deg, #000000 0%, #1a1a1a 50%, #000000 100%);
        }

        /* Animated Background Pattern */
        .sidebar::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: 
                radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
                radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
                radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
            background-size: 50px 50px, 80px 80px, 100px 100px;
            animation: backgroundFloat 30s ease-in-out infinite;
            pointer-events: none;
        }

        @keyframes backgroundFloat {
            0%, 100% { transform: translate(0, 0); }
            33% { transform: translate(-10px, -10px); }
            66% { transform: translate(10px, 10px); }
        }

        /* Custom Scrollbar */
        .sidebar::-webkit-scrollbar {
            width: 6px;
        }

        .sidebar::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
        }

        .sidebar::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.3);
            border-radius: 3px;
        }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        /* Enhanced Spacious Sidebar Header */
        .sidebar-header {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            padding: 3rem 2rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
            position: relative;
            z-index: 1;
            min-height: 220px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sidebar-header a {
            text-decoration: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1.5rem;
            width: 100%;
        }

        /* Enhanced Logo Container */
        .logo-container {
            width: 110px;
            height: 110px;
            background: white;
            border-radius: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
            transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }

        .logo-container::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, var(--primary-blue), var(--sky-blue));
            opacity: 0;
            transition: opacity 0.4s ease;
        }

        .logo-container::after {
            content: '';
            position: absolute;
            inset: -50%;
            background: conic-gradient(
                from 180deg at 50% 50%,
                rgba(255, 255, 255, 0) 0deg,
                rgba(255, 255, 255, 0.3) 180deg,
                rgba(255, 255, 255, 0) 360deg
            );
            animation: rotate 3s linear infinite;
            opacity: 0;
        }

        @keyframes rotate {
            100% { transform: rotate(360deg); }
        }

        .logo-container:hover::before {
            opacity: 1;
        }

        .logo-container:hover::after {
            opacity: 1;
        }

        .logo-container img {
            width: 100%;
            height: auto;
            position: relative;
            z-index: 1;
            transition: all 0.4s ease;
        }

        .sidebar-header a:hover .logo-container {
            transform: translateY(-8px) scale(1.08);
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
        }

        .sidebar-header a:hover .logo-container img {
            filter: brightness(0) invert(1);
            transform: scale(1.1);
        }

        /* Enhanced Brand Text */
        .brand-text {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            gap: 0.5rem;
        }

        .brand-name {
            font-size: 2.25rem;
            font-weight: 900;
            color: white;
            line-height: 1.1;
            letter-spacing: -1px;
            text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
        }

        .sidebar-header a:hover .brand-name {
            transform: scale(1.05);
            letter-spacing: 1px;
        }

        .brand-tagline {
            font-size: 0.85rem;
            color: rgba(255, 255, 255, 0.8);
            font-weight: 600;
            letter-spacing: 2px;
            text-transform: uppercase;
            padding: 0.5rem 1.5rem;
            background: rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            backdrop-filter: blur(5px);
            transition: all 0.3s ease;
        }

        .sidebar-header a:hover .brand-tagline {
            background: rgba(255, 255, 255, 0.25);
            letter-spacing: 3px;
        }

        /* Navigation Section */
        .nav {
            padding: 1.5rem 0;
            flex: 1;
        }

        .nav-section-title {
            padding: 1.5rem 1.75rem 0.75rem;
            font-size: 0.7rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: rgba(255, 255, 255, 0.5);
            margin-top: 1rem;
        }

        .nav-item {
            margin: 0.25rem 0;
            position: relative;
        }

        .nav-link {
            padding: 1.1rem 1.75rem;
            margin: 0 1rem;
            border-radius: 16px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            font-weight: 600;
            font-size: 0.95rem;
            color: rgba(255, 255, 255, 0.85);
            display: flex;
            align-items: center;
            gap: 1.25rem;
            position: relative;
            overflow: hidden;
            border: 2px solid transparent;
        }

        .nav-link::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: white;
            transform: scaleY(0);
            transition: transform 0.3s ease;
            border-radius: 0 4px 4px 0;
        }

        .nav-link::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
            opacity: 0;
            transition: opacity 0.3s ease;
            border-radius: 16px;
        }

        .nav-link:hover {
            color: white;
            transform: translateX(8px);
            border-color: rgba(255, 255, 255, 0.2);
        }

        .nav-link:hover::after {
            opacity: 1;
        }

        .nav-link:hover::before {
            transform: scaleY(1);
        }

        .nav-link.active {
            background: white;
            color: var(--primary-blue);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
            transform: translateX(0);
            border-color: white;
        }

        .nav-link.active::before {
            display: none;
        }

        .nav-link.active i {
            color: var(--primary-blue);
        }

        .nav-link i {
            width: 24px;
            text-align: center;
            font-size: 1.2rem;
            transition: all 0.3s ease;
        }

        .nav-link:hover i {
            transform: scale(1.15) rotate(5deg);
        }

        .nav-link .badge {
            margin-left: auto;
            background: var(--accent-gold);
            color: var(--navy-dark);
            font-weight: 700;
            font-size: 0.7rem;
            padding: 0.3rem 0.7rem;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        /* User Profile Section */
        .user-profile-section {
            margin-top: auto;
            padding: 1.25rem;
            border-top: 1px solid rgba(255, 255, 255, 0.15);
            background: rgba(0, 0, 0, 0.15);
            backdrop-filter: blur(10px);
        }

        .user-profile-card {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 16px;
            padding: 1.25rem;
            display: flex;
            align-items: center;
            gap: 1.25rem;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
            border: 2px solid rgba(255, 255, 255, 0.1);
            text-decoration: none;
            color: white;
        }

        .user-profile-card:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-4px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
            border-color: rgba(255, 255, 255, 0.3);
        }

        .user-avatar {
            width: 56px;
            height: 56px;
            border-radius: 16px;
            background: linear-gradient(135deg, white, rgba(255, 255, 255, 0.9));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.6rem;
            color: var(--primary-blue);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
            transition: all 0.3s ease;
        }

        .user-profile-card:hover .user-avatar {
            transform: scale(1.1) rotate(-5deg);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
        }

        .user-info {
            flex: 1;
        }

        .user-name {
            font-weight: 700;
            font-size: 1rem;
            color: white;
            margin-bottom: 0.2rem;
        }

        .user-role {
            font-size: 0.8rem;
            color: rgba(255, 255, 255, 0.7);
            font-weight: 500;
        }

        .user-actions {
            color: rgba(255, 255, 255, 0.6);
            font-size: 1.2rem;
            transition: all 0.3s ease;
        }

        .user-profile-card:hover .user-actions {
            color: white;
            transform: translateX(6px);
        }

        /* Premium Topbar */
        .topbar {
            margin-left: 300px;
            height: 85px;
            background: white;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 2.5rem;
            box-shadow: var(--shadow-md);
            position: sticky;
            top: 0;
            z-index: 999;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }

        /* Enhanced Search Bar */
        .search-container {
            position: relative;
            flex: 1;
            max-width: 500px;
            margin: 0 1.5rem;
        }

        .search-wrapper {
            position: relative;
            display: flex;
            align-items: center;
        }

        .search-wrapper i {
            position: absolute;
            left: 1rem;
            color: var(--text-light);
            font-size: 1rem;
            pointer-events: none;
            z-index: 1;
        }

        .search-input {
            width: 100%;
            height: 48px;
            padding: 0.5rem 1.25rem 0.5rem 3rem;
            border: 2px solid var(--border-color);
            border-radius: 14px;
            font-size: 0.9rem;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: var(--bg-light);
            font-weight: 500;
            color: var(--text-primary);
        }

        .search-input::placeholder {
            color: var(--text-light);
        }

        .search-input:focus {
            outline: none;
            border-color: var(--primary-blue);
            background: white;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
        }

        /* Sidebar Toggle Button */
        .sidebar-toggle {
            width: 52px;
            height: 52px;
            border-radius: 14px;
            border: none;
            background: linear-gradient(135deg, var(--primary-blue), var(--sky-blue));
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
            box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
        }

        .sidebar-toggle:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
        }

        .sidebar-toggle i {
            transition: transform 0.3s ease;
            font-size: 1.2rem;
        }

        .sidebar-toggle.active {
            background: linear-gradient(135deg, #64748b, #94a3b8);
            box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
        }

        .sidebar-toggle.active:hover {
            box-shadow: 0 6px 20px rgba(100, 116, 139, 0.4);
        }

        /* Mobile Toggle */
        .mobile-toggle {
            display: none;
            width: 52px;
            height: 52px;
            border-radius: 14px;
            border: none;
            background: linear-gradient(135deg, var(--primary-blue), var(--sky-blue));
            color: white;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
            box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
        }

        .mobile-toggle:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
        }

        .mobile-toggle i {
            font-size: 1.2rem;
        }

        /* Topbar Actions */
        .topbar-actions {
            display: flex;
            align-items: center;
            gap: 1.5rem;
        }

        .action-btn {
            width: 52px;
            height: 52px;
            border-radius: 16px;
            border: 2px solid var(--border-color);
            background: white;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
            position: relative;
            font-size: 1.15rem;
        }

        .action-btn:hover {
            background: var(--bg-light);
            border-color: var(--primary-blue);
            color: var(--primary-blue);
            transform: translateY(-4px);
            box-shadow: var(--shadow-md);
        }

        .action-btn .badge {
            position: absolute;
            top: -8px;
            right: -8px;
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
            font-size: 0.7rem;
            padding: 0.3rem 0.6rem;
            border-radius: 10px;
            font-weight: 700;
            box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
            min-width: 24px;
            animation: pulse 2s ease-in-out infinite;
        }

        @keyframes pulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); }
        }

        /* User Menu Button */
        .user-menu-btn {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.6rem 1.5rem;
            border-radius: 16px;
            border: 2px solid var(--border-color);
            background: white;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
        }

        .user-menu-btn:hover {
            background: var(--bg-light);
            border-color: var(--primary-blue);
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        .user-menu-avatar {
            width: 44px;
            height: 44px;
            border-radius: 14px;
            background: linear-gradient(135deg, var(--primary-blue), var(--sky-blue));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 700;
            font-size: 1rem;
            box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
        }

        .user-menu-name {
            font-weight: 600;
            font-size: 0.95rem;
            color: var(--text-primary);
        }

        .user-menu-icon {
            color: var(--text-light);
            font-size: 0.875rem;
            transition: transform 0.3s ease;
        }

        .user-menu-btn:hover .user-menu-icon {
            transform: rotate(180deg);
        }

        /* Main Content */
        .main-content {
            margin-left: 300px;
            padding: 2.5rem;
            min-height: calc(100vh - 85px);
            transition: all 0.3s ease;
        }

        /* Dropdown Menu Enhancements */
        .dropdown-menu {
            border: none;
            box-shadow: var(--shadow-lg);
            border-radius: 16px;
            padding: 0.75rem;
            margin-top: 0.75rem;
            min-width: 260px;
            animation: dropdownSlide 0.3s ease;
        }

        @keyframes dropdownSlide {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .dropdown-item {
            border-radius: 12px;
            padding: 1rem 1.5rem;
            font-size: 0.95rem;
            font-weight: 500;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 1rem;
            color: var(--text-primary);
        }

        .dropdown-item:hover {
            background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(56, 189, 248, 0.1));
            color: var(--primary-blue);
            transform: translateX(6px);
        }

        .dropdown-item i {
            width: 22px;
            text-align: center;
            color: var(--text-light);
            font-size: 1.15rem;
            transition: all 0.2s ease;
        }

        .dropdown-item:hover i {
            color: var(--primary-blue);
            transform: scale(1.15);
        }

        .dropdown-header {
            padding: 1rem 1.5rem;
            font-weight: 700;
            font-size: 0.8rem;
            color: var(--text-primary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .dropdown-divider {
            margin: 0.75rem 0;
            border-color: var(--border-color);
            opacity: 0.5;
        }

        /* Sidebar Collapsed State - Retract Halfway */
        body.sidebar-collapsed .sidebar {
            transform: translateX(-50%);
        }

        body.sidebar-collapsed .topbar {
            margin-left: 150px;
        }

        body.sidebar-collapsed .main-content {
            margin-left: 150px;
        }

        /* Responsive Design */
        @media (max-width: 991px) {
            .sidebar {
                transform: translateX(-100%);
            }

            .sidebar.show {
                transform: translateX(0);
            }

            .topbar {
                margin-left: 0;
            }

            .main-content {
                margin-left: 0;
                padding: 1.5rem;
            }

            .mobile-toggle {
                display: flex;
            }

            .sidebar-toggle {
                display: none;
            }

            .search-container {
                width: 250px;
            }

            .user-menu-name {
                display: none;
            }
        }

@media (max-width: 576px) {
            .search-container {
                display: none;
            }

            .topbar {
                padding: 0 1rem;
            }

            .topbar-actions {
                gap: 0.5rem;
            }

            .action-btn {
                width: 44px;
                height: 44px;
            }

            .main-content {
                padding: 1rem;
            }

            .sidebar-header {
                padding: 2rem 1.5rem;
                min-height: 180px;
            }

            .logo-container {
                width: 90px;
                height: 90px;
            }

            .logo-container img {
                width: 70px;
            }

            .brand-name {
                font-size: 1.75rem;
            }
        }

        /* Enhanced Print/PDF Styles - Remove ALL Navigation & Copyright */
        @media print {
            * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
            body { 
                background: white !important; 
                font-size: 11px !important; 
                padding: 0 !important; 
                margin: 0.5in !important;
            }
            
            /* Hide ALL navigation/header/footer */
            #sidebar,
            .sidebar,
            .topbar,
            header,
            nav,
            footer,
            .no-print,
            .no-print-pdf,
            .btn,
            button,
            form,
            .d-print-none,
            [class*="no-print"],
            .mobile-toggle,
            .sidebar-toggle,
            .search-container,
            .topbar-actions,
            .user-menu-btn,
            .dropdown,
            .modal { 
                display: none !important; 
            }
            
            /* Content layout */
            .main-content { 
                margin-left: 0 !important; 
                padding: 0 !important; 
                max-width: none !important;
            }
            
            /* Report containers */
            .card, 
            .report-container, 
            .metric-card, 
            .statement-container,
            .ledger-container,
            .report-shell { 
                box-shadow: none !important; 
                border: none !important; 
                border-radius: 0 !important;
                margin: 0 !important;
                page-break-inside: avoid;
            }
            
            /* Tables */
            table { 
                font-size: 10px !important; 
                width: 100% !important; 
            }
            th, td { padding: 6px 8px !important; }
            
            /* Backgrounds */
            .table-light, .table-secondary,
            [class*="bg-"], 
            .summary-card { 
                background: white !important; 
                -webkit-print-color-adjust: exact;
            }
        }
    </style>
    
    <?php echo $__env->yieldContent('styles'); ?>
    
    <!-- THIS IS THE FIX - ADDED <?php echo $__env->yieldPushContent('styles'); ?> -->
    <?php echo $__env->yieldPushContent('styles'); ?>
</head>
<body>
    <!-- Enhanced Sidebar -->
    <nav id="sidebar" class="sidebar">
        <!-- Spacious Premium Logo/Brand -->
        <div class="sidebar-header">
            <a href="<?php echo e(route('dashboard')); ?>">
                <div class="logo-container">
                    <img src="https://melsoftzim.co.zw/assets/uploads/logo.jpg" alt="Prolex Logo">
                </div>
                <div class="brand-text">
                    <span class="brand-name">Prolex</span>
                    <span class="brand-tagline">Legal Excellence</span>
                </div>
            </a>
        </div>

        <!-- Main Navigation -->
        <ul class="nav flex-column">
            <?php
                $authUser = auth()->user();
                $canAccessLexa = $authUser && $authUser->tier_id !== null && (int) $authUser->tier_id >= 1 && (int) $authUser->tier_id <= 4;
            ?>
            <li class="nav-section-title">Main Menu</li>
            <li class="nav-item">
                <a href="<?php echo e(route('dashboard')); ?>" class="nav-link <?php echo e(request()->routeIs('dashboard') ? 'active' : ''); ?>">
                    <i class="fas fa-home"></i>
                    <span>Dashboard</span>
                </a>
            </li>
            <?php if($authUser && $authUser->canAccessModule('edit-modules')): ?>
                <li class="nav-item">
                    <a href="<?php echo e(route('modules.edit')); ?>" class="nav-link <?php echo e(request()->routeIs('modules.edit*') ? 'active' : ''); ?>">
                        <i class="fas fa-edit"></i>
                        <span>Edit Menu</span>
                    </a>
                </li>
            <?php endif; ?>
            <?php if($authUser && $authUser->canAccessModule('processing-modules')): ?>
                <li class="nav-item">
                    <a href="<?php echo e(route('modules.processing')); ?>" class="nav-link <?php echo e(request()->routeIs('modules.processing*') ? 'active' : ''); ?>">
                        <i class="fas fa-cogs"></i>
                        <span>Processing Center</span>
                    </a>
                </li>
            <?php endif; ?>
<?php if($authUser && $authUser->canAccessModule('reports-modules')): ?>
    <li class="nav-item">
                    <a href="<?php echo e(route('modules.reports')); ?>" class="nav-link <?php echo e(request()->routeIs('modules.reports*') ? 'active' : ''); ?>">
                        <i class="fas fa-chart-line"></i>
                        <span>Reports</span>
                    </a>
                </li>

            <?php endif; ?>

            <li class="nav-section-title">Communication</li>
            <li class="nav-item">
                <a href="<?php echo e(route('chat.passcode')); ?>" class="nav-link <?php echo e(request()->routeIs('chat.*') ? 'active' : ''); ?>">
                    <i class="fas fa-comments"></i>
                    <span>Chat Room</span>
                </a>
            </li>

            <li class="nav-section-title">Lexa</li>
            <li class="nav-item">
                <?php if($canAccessLexa): ?>
                    <a href="<?php echo e(route('lexa.index')); ?>" class="nav-link <?php echo e(request()->routeIs('lexa.*') ? 'active' : ''); ?>">
                        <i class="fas fa-robot"></i>
                        <span>Lexa AI Assistant</span>
                    </a>
                <?php else: ?>
                    <a href="#" onclick="showUpgradeModal('Lexa AI Assistant'); return false;" class="nav-link">
                        <i class="fas fa-robot"></i>
                        <span>Lexa AI Assistant</span>
                    </a>
                <?php endif; ?>
            </li>

            <li class="nav-section-title">System</li>
            <?php if($authUser && $authUser->canAccessModule('administration')): ?>
                <li class="nav-item">
                    <a href="<?php echo e(route('administration')); ?>" class="nav-link <?php echo e(request()->routeIs('administration*') ? 'active' : ''); ?>">
                        <i class="fas fa-shield-alt"></i>
                        <span>Administration</span>
                    </a>
                </li>
            <?php endif; ?>
            <li class="nav-item">
                <a href="<?php echo e(route('help')); ?>" class="nav-link <?php echo e(request()->routeIs('help') ? 'active' : ''); ?>">
                    <i class="fas fa-question-circle"></i>
                    <span>Help Center</span>
                </a>
            </li>
        </ul>

        <!-- User Profile Section (Bottom) -->
        <div class="user-profile-section">
            <a href="<?php echo e(route('profile')); ?>" class="user-profile-card">
                <div class="user-avatar">
                    <i class="fas fa-user"></i>
                </div>
                <div class="user-info">
                    <div class="user-name"><?php echo e(auth()->user()->name ?? 'Guest'); ?></div>
                    <div class="user-role">View Profile</div>
                </div>
                <div class="user-actions">
                    <i class="fas fa-chevron-right"></i>
                </div>
            </a>
        </div>
    </nav>

    <!-- Premium Topbar -->
    <header class="topbar">
        <!-- Mobile Sidebar Toggle Button -->
        <button class="mobile-toggle" onclick="toggleSidebar()" aria-label="Open menu">
            <i class="fas fa-bars"></i>
        </button>

        <!-- Sidebar Toggle Button -->
        <button class="sidebar-toggle" id="sidebar-toggle" onclick="toggleSidebar()" aria-label="Toggle sidebar">
            <i class="fas fa-bars"></i>
        </button>

        <!-- Enhanced Search -->
        <div class="search-container">
            <input
                id="global-search-input"
                type="search"
                class="search-input"
                placeholder="Search cases, clients, documents..."
                aria-label="Search"
            />
        </div>

        <?php
            $pendingConflictCount = 0;
            $pendingConflictChecks = collect();
            $isConflictPartner = auth()->check()
                && (int) auth()->user()->group_id === 3
                && (int) auth()->user()->tier_id === 4;

            if ($isConflictPartner && \Illuminate\Support\Facades\Schema::hasTable('conflict_checks')) {
                $pendingConflictCount = \DB::table('conflict_checks')
                    ->where('status', 'Pending Review')
                    ->count();

                if ($pendingConflictCount > 0) {
                    $pendingConflictChecks = \DB::table('conflict_checks as cc')
                        ->leftJoin('users as u', 'u.id', '=', 'cc.requested_by')
                        ->select('cc.id', 'cc.created_at', 'u.name as requester_name')
                        ->where('cc.status', 'Pending Review')
                        ->orderByDesc('cc.created_at')
                        ->limit(5)
                        ->get();
                }
            }

            $diaryAssignmentCount = 0;
            $diaryAssignments = collect();
            $dailyTaskCount = 0;
            $dailyTasks = collect();

            $hasContextualDiary = \Illuminate\Support\Facades\Schema::hasTable('diary_contextual_entries');
            $hasQuickDiary = \Illuminate\Support\Facades\Schema::hasTable('diary_quick_entries');

            if (auth()->check() && $hasContextualDiary) {
                $diaryAssignmentCount = \App\Models\Diary::where('assigned_to', auth()->id())
                    ->where('task_type', 'assignment')
                    ->whereNotIn('status', ['completed', 'deferred'])
                    ->count();

                if ($diaryAssignmentCount > 0) {
                    $diaryAssignments = \App\Models\Diary::where('assigned_to', auth()->id())
                        ->where('task_type', 'assignment')
                        ->whereNotIn('status', ['completed', 'deferred'])
                        ->orderBy('date_time')
                        ->limit(5)
                        ->get();
                }

                $dailyContextualCount = \App\Models\Diary::whereDate('date_time', today())
                    ->where(function ($q) {
                        $q->whereNull('assigned_to')->orWhere('assigned_to', auth()->id());
                    })
                    ->whereNotIn('status', ['completed', 'deferred'])
                    ->count();

                $dailyTaskCount += $dailyContextualCount;

                if ($dailyContextualCount > 0) {
                    $dailyTasks = $dailyTasks->merge(
                        \App\Models\Diary::whereDate('date_time', today())
                            ->where(function ($q) {
                                $q->whereNull('assigned_to')->orWhere('assigned_to', auth()->id());
                            })
                            ->whereNotIn('status', ['completed', 'deferred'])
                            ->orderBy('date_time')
                            ->limit(5)
                            ->get()
                            ->map(function ($e) {
                                return [
                                    'type' => 'contextual',
                                    'id' => $e->id,
                                    'title' => $e->task_title,
                                    'when' => optional($e->date_time)->format('M d, H:i') ?? null,
                                ];
                            })
                    );
                }
            }

            if (auth()->check() && $hasQuickDiary) {
                $dailyQuickCount = \App\Models\DiaryQuickEntry::whereDate('entry_date', today())
                    ->where(function ($q) {
                        $q->whereNull('assigned_to')->orWhere('assigned_to', auth()->id());
                    })
                    ->count();

                $dailyTaskCount += $dailyQuickCount;

                if ($dailyQuickCount > 0) {
                    $dailyTasks = $dailyTasks->merge(
                        \App\Models\DiaryQuickEntry::whereDate('entry_date', today())
                            ->where(function ($q) {
                                $q->whereNull('assigned_to')->orWhere('assigned_to', auth()->id());
                            })
                            ->orderBy('entry_date')
                            ->limit(5)
                            ->get()
                            ->map(function ($e) {
                                return [
                                    'type' => 'quick',
                                    'id' => $e->id,
                                    'title' => $e->task_title,
                                    'when' => optional($e->entry_date)->format('M d') ?? null,
                                ];
                            })
                    );
                }
            }

            $dailyTasks = $dailyTasks->take(5);

            $totalNotificationCount = $pendingConflictCount + $diaryAssignmentCount + $dailyTaskCount;
        ?>

        <!-- Topbar Actions (Icons) -->
        <div class="topbar-actions">
            <!-- Notifications -->
            <div class="dropdown">
                <button class="action-btn" data-bs-toggle="dropdown" aria-expanded="false">
                    <i class="fas fa-bell"></i>
                    <?php if($totalNotificationCount > 0): ?>
                        <span class="badge"><?php echo e($totalNotificationCount); ?></span>
                    <?php endif; ?>
                </button>
                <ul class="dropdown-menu dropdown-menu-end">
                     <li class="dropdown-header">Notifications</li>
                     <?php if($totalNotificationCount > 0): ?>
                        <?php if($dailyTaskCount > 0): ?>
                            <li class="dropdown-header">Daily Tasks</li>
                            <?php $__currentLoopData = $dailyTasks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $task): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li>
                                    <a class="dropdown-item" href="<?php echo e(route('modules.processing.diary.entry.show', ['type' => $task['type'], 'id' => $task['id']])); ?>">
                                        <i class="fas fa-calendar-day"></i>
                                        <?php echo e($task['title']); ?>

                                        <?php if(!empty($task['when'])): ?>
                                            <span class="text-muted" style="font-size:.75rem;">
                                                — <?php echo e($task['when']); ?>

                                            </span>
                                        <?php endif; ?>
                                    </a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <li><hr class="dropdown-divider"></li>
                        <?php endif; ?>
                        <?php if($diaryAssignmentCount > 0): ?>
                            <li class="dropdown-header">Diary Assignments</li>
                            <?php $__currentLoopData = $diaryAssignments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assignment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li>
                                    <a class="dropdown-item" href="<?php echo e(route('modules.processing.diary.entry.show', ['type' => 'contextual', 'id' => $assignment->id])); ?>">
                                        <i class="fas fa-clipboard-check"></i>
                                        <?php echo e($assignment->task_title); ?>

                                        <span class="text-muted" style="font-size:.75rem;">
                                            — <?php echo e(optional($assignment->date_time)->format('M d, H:i')); ?>

                                        </span>
                                    </a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>

                        <?php if($pendingConflictCount > 0): ?>
                            <li><hr class="dropdown-divider"></li>
                            <li class="dropdown-header">Conflict Checks</li>
                            <?php $__currentLoopData = $pendingConflictChecks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $check): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li>
                                    <a class="dropdown-item" href="<?php echo e(route('modules.edit.matter-setup.conflicts')); ?>">
                                        <i class="fas fa-exclamation-triangle"></i>
                                        Pending conflict #<?php echo e($check->id); ?> (<?php echo e($check->requester_name ?? 'Unassigned'); ?>)
                                    </a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>

                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item text-center" href="<?php echo e(route('modules.processing.diary.list')); ?>"><strong>View Diary Entries</strong></a></li>
                    <?php else: ?>
                        <li><a class="dropdown-item" href="#"><i class="fas fa-file-alt"></i>New case assigned</a></li>
                        <li><a class="dropdown-item" href="#"><i class="fas fa-comment"></i>3 new messages</a></li>
                        <li><a class="dropdown-item" href="#"><i class="fas fa-calendar"></i>Hearing tomorrow</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item text-center" href="#"><strong>View All</strong></a></li>
                    <?php endif; ?>
                </ul>
            </div>

            <!-- Settings -->
            <a href="<?php echo e(route('system.settings')); ?>" class="action-btn" aria-label="System Settings">
                <i class="fas fa-cog"></i>
            </a>



            <!-- User Menu -->
            <div class="dropdown">
                <button class="user-menu-btn" data-bs-toggle="dropdown" aria-expanded="false">
                    <div class="user-menu-avatar"><?php echo e(strtoupper(substr(auth()->user()->name ?? 'G', 0, 1))); ?></div>
                    <span class="user-menu-name"><?php echo e(auth()->user()->name ?? 'Guest'); ?></span>
                    <i class="fas fa-chevron-down user-menu-icon"></i>
                </button>
                <ul class="dropdown-menu dropdown-menu-end">
                    <li class="dropdown-header">Account</li>
                    <li><a class="dropdown-item" href="<?php echo e(route('profile')); ?>"><i class="fas fa-user"></i>My Profile</a></li>
                    <li><a class="dropdown-item" href="<?php echo e(route('system.settings')); ?>"><i class="fas fa-cog"></i>Settings</a></li>
                    <li><a class="dropdown-item" href="<?php echo e(route('help')); ?>"><i class="fas fa-question-circle"></i>Help Center</a></li>
                    <li><hr class="dropdown-divider"></li>
                    <li>
                        <form method="POST" action="<?php echo e(route('logout')); ?>">
                            <?php echo csrf_field(); ?>
                            <button type="submit" class="dropdown-item">
                                <i class="fas fa-sign-out-alt"></i>Sign Out
                            </button>
                        </form>
                    </li>
                </ul>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="main-content">
        <?php echo $__env->yieldContent('content'); ?>
    </main>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

    <!-- Upgrade Modal -->
    <div class="modal fade" id="upgradeModal" tabindex="-1" aria-labelledby="upgradeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header" style="background: linear-gradient(135deg, #1e40af, #3b82f6); color: white;">
                    <h5 class="modal-title" id="upgradeModalLabel">
                        <i class="fas fa-gem me-2"></i>Premium Add-on
                    </h5>
                    <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body text-center py-4">
                    <div class="mb-3">
                        <i class="fas fa-lock fa-3x text-primary"></i>
                    </div>
                    <h4 id="upgradeFeatureName" class="mb-3">Feature Name</h4>
                    <p class="text-muted mb-3">
                        This feature is part of an add-on package. Contact us to upgrade your plan and unlock this functionality.
                    </p>
                    <div class="alert alert-info">
                        <i class="fas fa-envelope me-2"></i>
                        <strong>Email:</strong> info@zienetzim.co.zw
                    </div>
                    <p class="small text-muted">
                        Our team will be happy to assist you with package upgrades and provide dedicated support.
                    </p>
                </div>
                <div class="modal-footer justify-content-center">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                    <a href="mailto:info@zienetzim.co.zw?subject=Package Upgrade Request" class="btn btn-primary">
                        <i class="fas fa-paper-plane me-2"></i>Request Upgrade
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- Global Search Details Modal -->
    <div class="modal fade" id="globalSearchModal" tabindex="-1" aria-labelledby="globalSearchModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="globalSearchModalLabel" data-search-modal-title>Details</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body" data-search-modal-body>
                    <div class="py-3 text-center text-muted">Loading details...</div>
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn btn-primary" data-search-modal-open>Open full record</a>
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>

    <!-- Global utilities loaded via Vite -->
    <?php echo app('Illuminate\Foundation\Vite')(['resources/js/global.js', 'resources/js/search.js']); ?>

    <?php echo $__env->yieldPushContent('scripts'); ?>

    <script>
        // Close mobile sidebar when tapping outside or selecting a menu item
        document.addEventListener('DOMContentLoaded', function() {
            const sidebar = document.getElementById('sidebar');
            const mobileToggle = document.querySelector('.mobile-toggle');

            document.addEventListener('click', function(event) {
                if (window.innerWidth > 991 || !sidebar.classList.contains('show')) {
                    return;
                }

                const clickedInsideSidebar = sidebar.contains(event.target);
                const clickedToggle = mobileToggle && mobileToggle.contains(event.target);

                if (!clickedInsideSidebar && !clickedToggle) {
                    sidebar.classList.remove('show');
                }
            });

            sidebar.querySelectorAll('.nav-link').forEach((link) => {
                link.addEventListener('click', function() {
                    if (window.innerWidth <= 991) {
                        sidebar.classList.remove('show');
                    }
                });
            });
        });
        

        


        // Upgrade Modal function
        function showUpgradeModal(featureName) {
            document.getElementById('upgradeFeatureName').textContent = featureName;
            var modal = new bootstrap.Modal(document.getElementById('upgradeModal'));
            modal.show();
        }
    </script>


        <div class="container-fluid px-4">
            <div class="row align-items-center justify-content-center">
                <div class="col-12 text-center small text-body-secondary">
                    Copyright © Melsoft (Private) Limited. All Rights Reserved <?php echo e(date('Y')); ?>

                </div>
            </div>
        </div>
    </footer>
</body>
</html>
<?php /**PATH C:\Users\admin\Desktop\prolex\resources\views/layouts/master.blade.php ENDPATH**/ ?>