<?php $__env->startSection('title', 'إدارة المستخدمين'); ?>

<?php $__env->startPush('styles'); ?>
<style>
.admin-table-wrap .table, .admin-table-wrap table { background: var(--dark-800) !important; }
.admin-table-wrap th { background: var(--dark-700) !important; color: #9CA3BD !important; }
.admin-table-wrap td { background: transparent !important; color: #F0F1F5 !important; }
</style>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('page-title', 'إدارة المستخدمين'); ?>
<?php $__env->startSection('page-icon', 'fas fa-users'); ?>

<?php $__env->startSection('content'); ?>
<div class="row g-3 mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
                <div>
                    <i class="fas fa-users"></i>
                    قائمة المستخدمين
                </div>
                <div class="d-flex gap-2 flex-wrap">
                    <form method="GET" action="<?php echo e(route('admin.users')); ?>" class="d-flex gap-2">
                        <div class="input-group" style="max-width: 220px;">
                            <input type="text" class="form-control" name="search" id="searchInput"
                                   value="<?php echo e(request('search')); ?>" placeholder="البحث...">
                            <button class="btn btn-primary" type="submit">
                                <i class="fas fa-search"></i>
                            </button>
                        </div>
                        <select class="form-select" name="type" id="filterType" style="max-width: 140px;" onchange="this.form.submit()">
                            <option value="">جميع الأنواع</option>
                            <option value="driver" <?php echo e(request('type') == 'driver' ? 'selected' : ''); ?>>سائق</option>
                            <option value="passenger" <?php echo e(request('type') == 'passenger' ? 'selected' : ''); ?>>راكب</option>
                            <option value="admin" <?php echo e(request('type') == 'admin' ? 'selected' : ''); ?>>مدير</option>
                        </select>
                    </form>
                    <a href="<?php echo e(route('admin.users.create')); ?>" class="btn btn-primary">
                        <i class="fas fa-plus"></i> إضافة مستخدم
                    </a>
                </div>
            </div>
            <div class="card-body p-0">
                <?php if($users->count() > 0): ?>
                    <div class="table-responsive admin-table-wrap">
                        <table class="table admin-table">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>الاسم</th>
                                    <th>البريد الإلكتروني</th>
                                    <th>رقم الهاتف</th>
                                    <th>النوع</th>
                                    <th>الخدمة</th>
                                    <th>المحافظة</th>
                                    <th>المدينة</th>
                                    <th>الحالة</th>
                                    <th>التاريخ</th>
                                    <th>الإجراءات</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($user->id); ?></td>
                                        <td>
                                            <div class="d-flex align-items-center gap-2">
                                                <?php if($user->profile_image): ?>
                                                    <img src="<?php echo e(asset('storage/' . $user->profile_image)); ?>"
                                                         alt="صورة المستخدم" class="rounded-circle" width="36" height="36">
                                                <?php else: ?>
                                                    <div class="rounded-circle d-flex align-items-center justify-content-center"
                                                         style="width: 36px; height: 36px; background: var(--dark-600);">
                                                        <i class="fas fa-user" style="color: var(--text-muted);"></i>
                                                    </div>
                                                <?php endif; ?>
                                                <div>
                                                    <strong><?php echo e($user->name); ?></strong>
                                                    <?php if($user->user_type === 'admin'): ?>
                                                        <span class="badge badge-danger ms-1">مدير</span>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </td>
                                        <td><?php echo e($user->email); ?></td>
                                        <td><?php echo e($user->phone ?? 'غير محدد'); ?></td>
                                        <td>
                                            <?php switch($user->user_type):
                                                case ('driver'): ?>
                                                    <span class="badge badge-info"><i class="fas fa-user-tie me-1"></i>سائق</span>
                                                    <?php break; ?>
                                                <?php case ('passenger'): ?>
                                                    <span class="badge badge-success"><i class="fas fa-user me-1"></i>راكب</span>
                                                    <?php break; ?>
                                                <?php case ('admin'): ?>
                                                    <span class="badge badge-danger"><i class="fas fa-crown me-1"></i>مدير</span>
                                                    <?php break; ?>
                                                <?php case ('restaurant_manager'): ?>
                                                    <span class="badge badge-warning"><i class="fas fa-utensils me-1"></i>مدير مطعم</span>
                                                    <?php break; ?>
                                                <?php case ('gas_manager'): ?>
                                                    <span class="badge badge-info"><i class="fas fa-fire me-1"></i>مدير غاز</span>
                                                    <?php break; ?>
                                                <?php default: ?>
                                                    <span class="badge badge-secondary">غير محدد</span>
                                            <?php endswitch; ?>
                                        </td>
                                        <td>
                                            <?php switch($user->service_type):
                                                case ('taxi'): ?> <span class="badge badge-info">تاكسي</span> <?php break; ?>
                                                <?php case ('restaurant'): ?> <span class="badge badge-warning">مطعم</span> <?php break; ?>
                                                <?php case ('gas'): ?> <span class="badge badge-danger">غاز</span> <?php break; ?>
                                                <?php case ('all'): ?> <span class="badge badge-secondary">جميع الخدمات</span> <?php break; ?>
                                                <?php default: ?> <span class="badge badge-secondary">غير محدد</span>
                                            <?php endswitch; ?>
                                        </td>
                                        <td>
                                            <?php if($user->governorate): ?>
                                                <span class="badge badge-info"><?php echo e($user->governorate->name_ar); ?></span>
                                            <?php else: ?>
                                                <span style="color: var(--text-muted);">غير محدد</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if($user->city): ?>
                                                <span class="badge badge-secondary"><?php echo e($user->city->name_ar); ?></span>
                                            <?php else: ?>
                                                <span style="color: var(--text-muted);">غير محدد</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php switch($user->status):
                                                case ('active'): ?>
                                                    <span class="badge badge-success"><i class="fas fa-check-circle me-1"></i>نشط</span>
                                                    <?php break; ?>
                                                <?php case ('inactive'): ?>
                                                    <span class="badge badge-warning"><i class="fas fa-pause-circle me-1"></i>معطل</span>
                                                    <?php break; ?>
                                                <?php case ('suspended'): ?>
                                                    <span class="badge badge-danger"><i class="fas fa-ban me-1"></i>موقوف</span>
                                                    <?php break; ?>
                                                <?php default: ?>
                                                    <span class="badge badge-secondary">غير محدد</span>
                                            <?php endswitch; ?>
                                        </td>
                                        <td>
                                            <small style="color: var(--text-muted);"><?php echo e($user->created_at->format('Y-m-d')); ?></small>
                                            <br><small style="color: var(--text-muted);"><?php echo e($user->created_at->format('H:i')); ?></small>
                                        </td>
                                        <td>
                                            <div class="btn-group" role="group">
                                                <a href="<?php echo e(route('admin.users.show', $user->id)); ?>" class="btn btn-info btn-sm" title="عرض">
                                                    <i class="fas fa-eye"></i>
                                                </a>
                                                <a href="<?php echo e(route('admin.users.edit', $user->id)); ?>" class="btn btn-warning btn-sm" title="تعديل">
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form action="<?php echo e(route('admin.users.delete', $user->id)); ?>" method="POST" class="d-inline"
                                                      onsubmit="return confirm('هل أنت متأكد من حذف هذا المستخدم؟')">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="submit" class="btn btn-danger btn-sm" title="حذف">
                                                        <i class="fas fa-trash"></i>
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="d-flex justify-content-between align-items-center p-3 border-top" style="border-color: rgba(255,255,255,0.04) !important;">
                        <div style="color: var(--text-muted); font-size: 13px;">
                            عرض <?php echo e($users->firstItem() ?? 0); ?> إلى <?php echo e($users->lastItem() ?? 0); ?> من أصل <?php echo e($users->total()); ?>

                        </div>
                        <?php echo e($users->appends(request()->query())->links('pagination::bootstrap-4')); ?>

                    </div>
                <?php else: ?>
                    <div class="empty-state">
                        <i class="fas fa-users d-block"></i>
                        لا يوجد مستخدمين
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
document.getElementById('searchInput')?.addEventListener('keypress', function(e) {
    if (e.key === 'Enter') this.form.submit();
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\taxi_app\resources\views/admin/users/index.blade.php ENDPATH**/ ?>