<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Users - 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">
    
    <!-- Inline CSS for styling (Consistent with login & dashboard, pure Vanilla CSS) -->
    <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;

            /* Metrics 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;
            
            --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;
        }

        /* Global Reset & Base Styling */
        * {
            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;
        }

        /* Scrollbar customization */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        ::-webkit-scrollbar-track {
            background: transparent;
        }
        ::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

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

        /* Main Content Panel 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;
        }

        /* Left section: Hamburger (mobile), title badge */
        .topbar-left {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .menu-toggle-btn {
            display: none;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            width: 40px;
            height: 40px;
            border-radius: 8px;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-label);
            transition: all 0.2s ease;
        }

        .menu-toggle-btn:hover {
            background-color: var(--primary-light);
            color: var(--primary-color);
            border-color: var(--primary-color);
        }

        .menu-toggle-btn svg {
            width: 1.25rem;
            height: 1.25rem;
        }

        /* Top badge capsule e.g. "3. Users Management" */
        .top-badge {
            background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
            color: #ffffff;
            padding: 0.5rem 1rem;
            border-radius: 9999px;
            font-size: 0.875rem;
            font-weight: 700;
            box-shadow: 0 4px 10px rgba(59, 70, 241, 0.15);
            display: flex;
            align-items: center;
            gap: 0.375rem;
        }

        /* Right section: Calendar & 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);
        }

        /* Pure CSS avatar (Initial-based gradient fallback) */
        .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);
        }

        /* Online indicator dot */
        .online-dot {
            width: 10px;
            height: 10px;
            background-color: #10b981;
            border: 2px solid var(--bg-card);
            border-radius: 50%;
            position: absolute;
            bottom: 0;
            right: 0;
        }

        .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;
        }

        /* Clear button inside search */
        .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 User Button styling */
        .add-user-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-user-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-user-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;
        }

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

        .users-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;
        }

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

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

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

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

        /* Table columns detail style */
        .user-name-bold {
            font-weight: 700;
            color: var(--text-main);
        }

        .user-email-text {
            color: var(--text-muted);
            font-weight: 500;
        }

        /* Badges for roles and status */
        .role-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-badge {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.625rem;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 700;
        }

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

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

        /* 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-delete {
            background-color: #fef2f2;
            border-color: rgba(239, 68, 68, 0.15);
            color: #ef4444;
        }

        .action-icon-delete:hover {
            color: #ffffff;
            border-color: #ef4444;
            background-color: #ef4444;
            transform: scale(1.05);
        }

        .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);
        }

        /* Mobile Sidebar Backdrop shadow */
        .sidebar-backdrop {
            display: none;
            position: fixed;
            inset: 0;
            background-color: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(4px);
            z-index: 90;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .sidebar-backdrop.active {
            display: block;
            opacity: 1;
        }

        /* 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 STYLES (Mobile / Tablet adaptations)
           ========================================================================== */
        @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-user-btn {
                justify-content: center;
            }

        }
    </style>
</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' => 'Users'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?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; ?>

            <div class="card table-card">
                <div style="padding: 1.5rem 1.5rem 0 1.5rem;">
                    <div class="table-actions-bar">
                        <form method="GET" action="<?php echo e(route('users.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" placeholder="Search users..." id="searchInput">
                            
                            <?php if(!empty($search)): ?>
                                <button type="button" class="search-clear-btn" onclick="window.location.href='<?php echo e(route('users.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>

                        <a href="<?php echo e(route('users.create')); ?>" class="add-user-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 User</span>
                        </a>
                    </div>
                </div>

                <div class="table-responsive">
                    <table class="users-table">
                        <thead>
                            <tr>
                                <th style="width: 80px;">S.No.</th>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Role</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td>
                                        <span style="font-weight: 600; color: var(--text-muted);"><?php echo e(($users->currentPage() - 1) * $users->perPage() + $loop->iteration); ?></span>
                                    </td>
                                    <td>
                                        <span class="user-name-bold"><?php echo e($user['name']); ?></span>
                                    </td>
                                    <td>
                                        <span class="user-email-text"><?php echo e($user['email']); ?></span>
                                    </td>
                                    <td>
                                        <span class="role-badge"><?php echo e($user['role']); ?></span>
                                    </td>
                                    <td>
                                        <div class="action-buttons-wrap">
                                            <!-- Delete button -->
                                            <a href="<?php echo e(route('users.delete', $user['email'])); ?>" 
                                               class="action-icon-btn action-icon-delete" 
                                               onclick="return confirm('Are you sure you want to delete user <?php echo e($user['name']); ?>?');"
                                               title="Delete user">
                                                <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="5" 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 users 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' => $users, 'resourceName' => 'users'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            </div>
        </main>
    </div>

    <!-- JavaScript code block for interactions -->
    <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)
                            .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';
                                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);
                            });
                    }, 500);
                });
            }
        });
    </script>
</body>
</html>
<?php /**PATH /home/sainikcanteen/public_html/tFDataask/resources/views/admin/users/users.blade.php ENDPATH**/ ?>