<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Projects - Task Panel</title>
    
    <!-- Google 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=Instrument+Sans:ital,wght@0,400..700;1,400..700&display=swap" rel="stylesheet">
    
    <script>
        if (window.location.search) {
            const navEntries = performance.getEntriesByType("navigation");
            if ((navEntries.length > 0 && navEntries[0].type === "reload") || (performance.navigation && performance.navigation.type === 1)) {
                window.location.replace(window.location.pathname);
            }
        }
    </script>
    <style>
        /* CSS Custom Variables */
        :root {
            --primary-color: #3b46f1;
            --primary-hover: #2a35d8;
            --primary-light: #eff6ff;
            --bg-main: #f8fafc;
            --bg-card: #ffffff;
            
            --text-main: #0f172a;
            --text-muted: #64748b;
            --text-label: #334155;
            --border-color: #e2e8f0;
            --border-hover: #cbd5e1;
            --font-family: 'Instrument Sans', sans-serif;

            /* Status Theme Colors */
            --color-completed: #10b981;
            --color-completed-light: #ecfdf5;
            --color-progress: #3b82f6;
            --color-progress-light: #eff6ff;
            --color-pending: #f59e0b;
            --color-pending-light: #fffbeb;
            --color-hold: #ef4444;
            --color-hold-light: #fef2f2;
            --color-cancelled: #64748b;
            --color-cancelled-light: #f1f5f9;
            
            --sidebar-width: 260px;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
            --border-radius: 12px;
        }

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

        body {
            font-family: var(--font-family);
            background-color: var(--bg-main);
            color: var(--text-main);
            min-height: 100vh;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            overflow-x: hidden;
        }

        /* Main Page Layout Wrapper */
        .dashboard-layout {
            display: flex;
            position: relative;
            min-height: 100vh;
        }

        /* Main Content Area */
        .main-content {
            margin-left: var(--sidebar-width);
            flex-grow: 1;
            padding: 2rem;
            display: flex;
            flex-direction: column;
            gap: 2rem;
            min-width: 0;
            transition: margin-left 0.3s ease;
        }

        /* Topbar Header Area */
        .topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1.5rem;
            flex-wrap: wrap;
        }

        /* Right section: Admin Profile */
        .topbar-right {
            display: flex;
            align-items: center;
            gap: 1rem;
            margin-left: auto;
        }

        /* User Admin profile badge */
        .admin-profile {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            background-color: var(--bg-card);
            padding: 0.375rem 0.875rem 0.375rem 0.375rem;
            border-radius: 50px;
            border: 1px solid var(--border-color);
            box-shadow: var(--shadow-sm);
        }

        .avatar-initials {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(135deg, #4f46e5, #3b82f6);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #ffffff;
            font-weight: 700;
            font-size: 0.875rem;
            position: relative;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        .admin-info {
            display: flex;
            flex-direction: column;
            line-height: 1.2;
        }

        .admin-name {
            font-size: 0.875rem;
            font-weight: 700;
            color: var(--text-main);
        }

        .admin-role {
            font-size: 0.75rem;
            color: var(--text-muted);
            font-weight: 500;
        }

        /* Title Area */
        .dashboard-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            animation: fadeIn 0.5s ease-out;
        }

        .dashboard-title {
            font-size: 1.875rem;
            font-weight: 800;
            letter-spacing: -0.03em;
            color: var(--text-main);
        }

        /* Card Component base styling */
        .card {
            background-color: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 1.5rem;
            box-shadow: var(--shadow-sm);
            transition: all 0.3s ease;
        }

        /* Filters and Actions Bar above Table */
        .table-actions-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
            margin-bottom: 1.5rem;
            animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
        }

        /* Search Form Input */
        .search-form {
            position: relative;
            max-width: 320px;
            width: 100%;
        }

        .search-input {
            width: 100%;
            padding: 0.625rem 1rem 0.625rem 2.5rem;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 0.875rem;
            color: var(--text-main);
            background-color: var(--bg-card);
            transition: all 0.2s ease;
            box-shadow: var(--shadow-sm);
        }

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

        .search-input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(59, 70, 241, 0.15);
        }

        .search-icon {
            position: absolute;
            left: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            pointer-events: none;
            width: 1.125rem;
            height: 1.125rem;
            stroke-width: 2;
        }

        .search-clear-btn {
            position: absolute;
            right: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            border: none;
            background: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0.125rem;
            border-radius: 50%;
        }

        .search-clear-btn:hover {
            background-color: var(--primary-light);
            color: var(--primary-color);
        }

        .search-clear-btn svg {
            width: 0.875rem;
            height: 0.875rem;
        }

        /* Add Project Button styling */
        .add-project-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            background-color: var(--primary-color);
            color: #ffffff;
            padding: 0.625rem 1.125rem;
            border-radius: 8px;
            font-size: 0.875rem;
            font-weight: 700;
            text-decoration: none;
            box-shadow: 0 4px 6px -1px rgba(59, 70, 241, 0.1), 0 2px 4px -1px rgba(59, 70, 241, 0.06);
            transition: all 0.2s ease;
            cursor: pointer;
            border: none;
        }

        .add-project-btn:hover {
            background-color: var(--primary-hover);
            box-shadow: 0 10px 15px -3px rgba(59, 70, 241, 0.2), 0 4px 6px -2px rgba(59, 70, 241, 0.1);
        }

        .add-project-btn svg {
            width: 1.125rem;
            height: 1.125rem;
            stroke-width: 2.5;
        }

        /* Table Card & Responsive container */
        .table-card {
            padding: 0;
            overflow: hidden;
            animation: slideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .table-responsive {
            width: 100%;
            overflow-x: auto;
        }

        .projects-table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
        }

        .projects-table th {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            font-weight: 700;
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border-color);
            background-color: #fafafb;
        }

        .projects-table td {
            padding: 1.1rem 1.5rem;
            border-bottom: 1px solid var(--border-color);
            font-size: 0.9rem;
            color: var(--text-label);
        }

        .projects-table tr:last-child td {
            border-bottom: none;
        }

        .projects-table tbody tr {
            transition: background-color 0.2s ease;
        }

        .projects-table tbody tr:hover {
            background-color: #fafafb;
        }

        .project-name-bold {
            font-weight: 700;
            color: var(--text-main);
        }


        /* Type Badges */
        .type-badge {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.625rem;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 700;
            background-color: var(--bg-main);
            color: var(--text-muted);
            border: 1px solid var(--border-color);
        }

        /* Status Badges */
        .status-badge {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.75rem;
            border-radius: 50px;
            font-size: 0.75rem;
            font-weight: 700;
        }

        select.status-badge {
            border: none;
            cursor: pointer;
            outline: none;
            padding-right: 1.4rem;
            appearance: none;
            background-repeat: no-repeat;
            background-position: right 0.45rem center;
            background-size: 0.65rem;
            font-family: inherit;
            font-weight: 700;
            text-align: left;
        }

        select.status-badge option {
            font-weight: 600;
        }

        select.status-badge option[value="Pending"] {
            background-color: var(--color-pending-light) !important;
            color: var(--color-pending) !important;
        }

        select.status-badge option[value="In Progress"] {
            background-color: var(--color-progress-light) !important;
            color: var(--color-progress) !important;
        }

        select.status-badge option[value="On Hold"] {
            background-color: var(--color-hold-light) !important;
            color: var(--color-hold) !important;
        }

        select.status-badge option[value="Cancelled"] {
            background-color: var(--color-cancelled-light) !important;
            color: var(--color-cancelled) !important;
        }

        select.status-badge option[value="Completed"] {
            background-color: var(--color-completed-light) !important;
            color: var(--color-completed) !important;
        }

        .status-completed {
            background-color: var(--color-completed-light);
            color: var(--color-completed);
        }

        .status-inprogress {
            background-color: var(--color-progress-light);
            color: var(--color-progress);
        }

        .status-pending {
            background-color: var(--color-pending-light);
            color: var(--color-pending);
        }

        .status-hold {
            background-color: var(--color-hold-light);
            color: var(--color-hold);
        }

        .status-cancelled {
            background-color: var(--color-cancelled-light);
            color: var(--color-cancelled);
        }

        /* Action Buttons */
        .action-buttons-wrap {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .action-icon-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 6px;
            border: 1px solid var(--border-color);
            background-color: var(--bg-card);
            color: var(--text-muted);
            cursor: pointer;
            transition: all 0.2s ease;
            text-decoration: none;
        }

        .action-icon-edit:hover {
            color: var(--primary-color);
            border-color: var(--primary-color);
            background-color: var(--primary-light);
        }

        .action-icon-view:hover {
            color: var(--primary-color);
            border-color: var(--primary-color);
            background-color: var(--primary-light);
        }

        .action-icon-delete:hover {
            color: var(--color-hold);
            border-color: var(--color-hold);
            background-color: var(--color-hold-light);
        }

        .action-icon-btn svg {
            width: 1.125rem;
            height: 1.125rem;
            stroke-width: 2;
        }


        /* Alert notifications */
        .alert-success {
            background-color: var(--color-completed-light);
            border-left: 4px solid var(--color-completed);
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1.5rem;
            box-shadow: var(--shadow-sm);
            display: flex;
            align-items: center;
            font-size: 0.875rem;
            font-weight: 600;
            color: #065f46;
            animation: fadeIn 0.4s ease-out;
        }

        .alert-success svg {
            width: 1.25rem;
            height: 1.25rem;
            margin-right: 0.5rem;
            color: var(--color-completed);
        }

        /* General Animation keyframes */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(16px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Responsive */
        @media (max-width: 1024px) {
            .main-content {
                margin-left: 0;
                padding: 1.5rem;
            }
        }

        @media (max-width: 640px) {
            .table-actions-bar {
                flex-direction: column;
                align-items: stretch;
            }
            .search-form {
                max-width: 100%;
            }
            .add-project-btn {
                justify-content: center;
            }
        }

        /* Project View Modal dialog */
        .modal {
            position: fixed;
            inset: 0;
            background-color: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(4px);
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s ease;
            padding: 1.5rem;
        }

        .modal.active {
            opacity: 1;
            pointer-events: auto;
        }

        .modal-card {
            background-color: #ffffff;
            border-radius: 16px;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            width: 100%;
            max-width: 500px;
            overflow: hidden;
            transform: scale(0.9);
            transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .modal.active .modal-card {
            transform: scale(1);
        }

        .modal-header {
            padding: 1.5rem;
            border-bottom: 1px solid #f1f5f9;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #fdfdfd;
        }

        .modal-title {
            font-size: 1.15rem;
            font-weight: 800;
            color: #0e1c59;
        }

        .modal-close {
            background: none;
            border: none;
            color: #94a3b8;
            cursor: pointer;
            padding: 0.25rem;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .modal-close:hover {
            background-color: #f1f5f9;
            color: #64748b;
        }

        .modal-close svg {
            width: 1.25rem;
            height: 1.25rem;
            stroke-width: 2.5;
        }

        .modal-body {
            padding: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 1.25rem;
        }

        .modal-field {
            display: flex;
            flex-direction: column;
            gap: 0.375rem;
        }

        .modal-label {
            font-size: 0.75rem;
            text-transform: uppercase;
            font-weight: 700;
            color: var(--text-muted);
            letter-spacing: 0.05em;
        }

        .modal-value {
            font-size: 0.95rem;
            color: var(--text-main);
            font-weight: 600;
        }
    </style>
    <!-- Favicon -->
    <link rel="icon" type="image/png" href="<?php echo e(asset('images/faviocntaskpannel.png')); ?>">
</head>
<body>

    <div class="dashboard-layout">

        <?php echo $__env->make('admin.sidebar.sidebar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

        <main class="main-content">
            <?php echo $__env->make('admin.sidebar.topbar', ['title' => 'Projects'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <!-- Status Alerts -->
            <?php if(session('success')): ?>
                <div class="alert-success">
                    <svg fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                    </svg>
                    <span><?php echo e(session('success')); ?></span>
                </div>
            <?php endif; ?>

            <!-- Main Listing Card -->
            <div class="card table-card">
                
                <!-- Actions Bar: Search and "+ Add Project" -->
                <div style="padding: 1.5rem 1.5rem 0 1.5rem;">
                    <div class="table-actions-bar">
                        <!-- Search Form (filters table) -->
                        <form method="GET" action="<?php echo e(route('projects.index')); ?>" class="search-form">
                            <svg class="search-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
                            </svg>
                            <input type="text" name="search" value="<?php echo e($search); ?>" class="search-input" id="searchInput" placeholder="Search projects...">
                            
                            <?php if(!empty($search)): ?>
                                <button type="button" class="search-clear-btn" onclick="window.location.href='<?php echo e(route('projects.index')); ?>'" title="Clear search">
                                    <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                        <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
                                    </svg>
                                </button>
                            <?php endif; ?>
                        </form>

                        <!-- Add Project Link Button -->
                        <a href="<?php echo e(route('projects.create')); ?>" class="add-project-btn">
                            <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4"></path>
                            </svg>
                            <span>Add Project</span>
                        </a>
                    </div>
                </div>

                <!-- Table View -->
                <div class="table-responsive">
                    <table class="projects-table">
                        <thead>
                            <tr>
                                <th style="width: 80px;">S.No.</th>
                                <th>Project Name</th>
                                <th>Type (App/Web)</th>
                                <!-- <th>Status</th> -->
                                <th style="width: 120px;">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $projects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $project): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td>
                                        <span style="font-weight: 700; color: var(--text-muted);"><?php echo e(($projects->currentPage() - 1) * $projects->perPage() + $index + 1); ?></span>
                                    </td>
                                    <td>
                                        <span class="project-name-bold"><?php echo e($project['name']); ?></span>
                                    </td>
                                    <td>
                                        <span class="type-badge"><?php echo e($project['type']); ?></span>
                                    </td>
                                    <!-- <td>
                                        <?php
                                            $statusClass = 'inprogress';
                                            $statusLower = strtolower(str_replace(' ', '', $project['status']));
                                            if ($statusLower === 'completed') $statusClass = 'completed';
                                            elseif ($statusLower === 'pending') $statusClass = 'pending';
                                            elseif ($statusLower === 'onhold' || $statusLower === 'hold') $statusClass = 'hold';
                                            elseif ($statusLower === 'cancelled') $statusClass = 'cancelled';
                                        ?>
                                        <select id="project-status-select-<?php echo e($project['id']); ?>" class="status-badge status-<?php echo e($statusClass); ?>" onchange="updateProjectStatus(<?php echo e($project['id']); ?>, this)" style="border: none; cursor: pointer; outline: none; padding-right: 1.5rem; appearance: none; background-image: url('data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 24 24\' fill=\'none\' stroke=\'%2364748b\' stroke-width=\'3\' stroke-linecap=\'round\' stroke-linejoin=\'round\'><polyline points=\'6 9 12 15 18 9\'></polyline></svg>'); background-repeat: no-repeat; background-position: right 0.4rem center; background-size: 0.65rem;">
                                            <option value="Pending" <?php echo e($project['status'] === 'Pending' ? 'selected' : ''); ?>>Pending</option>
                                            <option value="In Progress" <?php echo e($project['status'] === 'In Progress' ? 'selected' : ''); ?>>In Progress</option>
                                            <option value="On Hold" <?php echo e($project['status'] === 'On Hold' || $project['status'] === 'Hold' ? 'selected' : ''); ?>>On Hold</option>
                                            <option value="Cancelled" <?php echo e($project['status'] === 'Cancelled' ? 'selected' : ''); ?>>Cancelled</option>
                                            <option value="Completed" <?php echo e($project['status'] === 'Completed' ? 'selected' : ''); ?>>Completed</option>
                                        </select>
                                    </td> -->
                                    <td>
                                        <div class="action-buttons-wrap">
                                            <!-- View button -->
                                            <a href="<?php echo e(route('projects.viewproject', $project['id'])); ?>" class="action-icon-btn action-icon-view" title="View project details">
                                                <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
                                                </svg>
                                            </a>
                                         
                                            <!-- Delete button -->
                                            <a href="<?php echo e(route('projects.delete', $project['name'])); ?>" 
                                               class="action-icon-btn action-icon-delete" 
                                               onclick="return confirm('Are you sure you want to delete project: <?php echo e($project['name']); ?>?');"
                                               title="Delete project">
                                                <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                                    <path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
                                                </svg>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" style="text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);">
                                        <div style="display: flex; flex-direction: column; align-items: center; gap: 0.5rem;">
                                            <svg style="width: 2.5rem; height: 2.5rem; color: #cbd5e1;" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                                <path stroke-linecap="round" stroke-linejoin="round" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                            </svg>
                                            <span style="font-weight: 600; font-size: 0.95rem;">No projects found</span>
                                            <span style="font-size: 0.85rem;">Try adjusting your keywords or clear search filters.</span>
                                        </div>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>

                <!-- Footer Pagination -->
                <?php echo $__env->make('common.pagination', ['paginator' => $projects, 'resourceName' => 'projects'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            </div>
        </main>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {

            // Auto hide success alerts after 3 seconds
            const successAlert = document.querySelector('.alert-success');
            if (successAlert) {
                setTimeout(() => {
                    successAlert.style.transition = 'opacity 0.5s ease';
                    successAlert.style.opacity = '0';
                    setTimeout(() => {
                        successAlert.remove();
                    }, 500);
                }, 3000);
            }

            // AJAX Live Search
            const searchInput = document.getElementById('searchInput');
            let searchTimeout;

            if (searchInput) {
                searchInput.addEventListener('input', function() {
                    clearTimeout(searchTimeout);
                    searchTimeout = setTimeout(() => {
                        const query = this.value;
                        const url = new URL(window.location.href);
                        if (query) {
                            url.searchParams.set('search', query);
                        } else {
                            url.searchParams.delete('search');
                        }
                        
                        fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' } })
                            .then(response => response.text())
                            .then(html => {
                                const parser = new DOMParser();
                                const doc = parser.parseFromString(html, 'text/html');
                                
                                const newTable = doc.querySelector('.table-responsive');
                                const currentTable = document.querySelector('.table-responsive');
                                if (newTable && currentTable) {
                                    currentTable.innerHTML = newTable.innerHTML;
                                }
                                
                                const paginationSelector = 'nav, .pagination-container';
                                const newPagination = doc.querySelector(paginationSelector);
                                const currentPagination = document.querySelector(paginationSelector);
                                if (newPagination && currentPagination) {
                                    currentPagination.innerHTML = newPagination.innerHTML;
                                } else if (newPagination && !currentPagination) {
                                    currentTable.insertAdjacentHTML('afterend', newPagination.outerHTML);
                                } else if (!newPagination && currentPagination) {
                                    currentPagination.remove();
                                }

                                window.history.replaceState({}, '', url);
                            });
                    }, 100);
                });
            }
        });
    </script>
</body>
</html>
<?php /**PATH D:\New\New\admin-panel\resources\views/admin/projects/project.blade.php ENDPATH**/ ?>