<?php $__env->startSection('title', 'Kelola User - Admin'); ?>
<?php $__env->startSection('content'); ?>
<div>
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:1rem;margin-bottom:2rem">
    <div>
        <h1 class="page-title">Kelola User</h1>
        <p class="page-subtitle">Total <?php echo e($stats['total']); ?> user terdaftar</p>
    </div>
    <a href="<?php echo e(route('admin.users.create')); ?>" class="btn btn-primary">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
        Tambah User
    </a>
</div>


<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:1rem;margin-bottom:1.5rem">
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = [['Total',    $stats['total'],  '#DBEAFE','#1A56DB'],['Aktif', $stats['active'],'#D1FAE5','#059669'],['Dinonaktifkan',$stats['banned'],'#FEE2E2','#DC2626'],['Admin',$stats['admin'],'#EDE9FE','#7C3AED']]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$l,$v,$bg,$c]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
    <div style="background:#fff;border:1px solid #E2E8F0;border-radius:12px;padding:1rem;display:flex;align-items:center;gap:10px">
        <div style="width:36px;height:36px;border-radius:9px;background:<?php echo e($bg); ?>;display:flex;align-items:center;justify-content:center;font-size:1rem;font-weight:800;color:<?php echo e($c); ?>"><?php echo e($v); ?></div>
        <div style="font-size:.8125rem;color:#64748B"><?php echo e($l); ?></div>
    </div>
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
</div>


<div class="card" style="margin-bottom:1.25rem;padding:1rem 1.25rem">
    <form method="GET" style="display:flex;gap:.75rem;flex-wrap:wrap;align-items:flex-end">
        <div style="flex:1;min-width:200px">
            <label style="font-size:.8rem;font-weight:600;color:#64748B;display:block;margin-bottom:4px">Cari</label>
            <input type="text" name="search" value="<?php echo e(request('search')); ?>" class="form-control" placeholder="Nama atau email..." style="height:38px">
        </div>
        <div>
            <label style="font-size:.8rem;font-weight:600;color:#64748B;display:block;margin-bottom:4px">Role</label>
            <select name="role" class="form-control" style="height:38px;width:120px">
                <option value="">Semua</option>
                <option value="user" <?php echo e(request('role')==='user'?'selected':''); ?>>User</option>
                <option value="admin" <?php echo e(request('role')==='admin'?'selected':''); ?>>Admin</option>
            </select>
        </div>
        <div>
            <label style="font-size:.8rem;font-weight:600;color:#64748B;display:block;margin-bottom:4px">Status</label>
            <select name="status" class="form-control" style="height:38px;width:140px">
                <option value="">Semua</option>
                <option value="active" <?php echo e(request('status')==='active'?'selected':''); ?>>Aktif</option>
                <option value="banned" <?php echo e(request('status')==='banned'?'selected':''); ?>>Dinonaktifkan</option>
            </select>
        </div>
        <button type="submit" class="btn btn-primary btn-sm" style="height:38px">Filter</button>
        <a href="<?php echo e(route('admin.users.index')); ?>" class="btn btn-secondary btn-sm" style="height:38px">Reset</a>
    </form>
</div>


<div class="card" style="padding:0">
    <div class="table-wrapper">
        <table class="table">
            <thead>
                <tr>
                    <th>User</th>
                    <th>Role</th>
                    <th style="text-align:center">Analisis</th>
                    <th>Bergabung</th>
                    <th style="text-align:center">Status</th>
                    <th style="text-align:center">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                <tr>
                    <td>
                        <div style="display:flex;align-items:center;gap:10px">
                            <div style="width:36px;height:36px;border-radius:9px;background:<?php echo e($u->isAdmin()?'linear-gradient(135deg,#7C3AED,#A855F7)':'linear-gradient(135deg,#1A56DB,#06B6D4)'); ?>;display:flex;align-items:center;justify-content:center;color:white;font-weight:700;font-size:.875rem;flex-shrink:0">
                                <?php echo e(strtoupper(substr($u->name,0,1))); ?>

                            </div>
                            <div>
                                <div style="font-weight:600;color:#1E293B"><?php echo e($u->name); ?></div>
                                <div style="font-size:.75rem;color:#94A3B8"><?php echo e($u->email); ?></div>
                            </div>
                        </div>
                    </td>
                    <td>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($u->isAdmin()): ?>
                        <span style="background:#EDE9FE;color:#7C3AED;padding:3px 10px;border-radius:20px;font-size:.75rem;font-weight:700">Admin</span>
                        <?php else: ?>
                        <span style="background:#F1F5F9;color:#64748B;padding:3px 10px;border-radius:20px;font-size:.75rem;font-weight:700">User</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </td>
                    <td style="text-align:center;font-weight:700;color:#1E293B"><?php echo e($u->analyses_count); ?></td>
                    <td style="font-size:.8125rem;color:#64748B"><?php echo e($u->created_at->format('d/m/Y')); ?></td>
                    <td style="text-align:center">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($u->isBanned()): ?>
                        <span style="background:#FEE2E2;color:#991B1B;padding:3px 10px;border-radius:20px;font-size:.75rem;font-weight:700">Nonaktif</span>
                        <?php else: ?>
                        <span style="background:#D1FAE5;color:#065F46;padding:3px 10px;border-radius:20px;font-size:.75rem;font-weight:700">Aktif</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </td>
                    <td style="text-align:center">
                        <div style="display:flex;align-items:center;justify-content:center;gap:6px">
                            <a href="<?php echo e(route('admin.users.show',$u->id)); ?>" style="color:#1A56DB" title="Detail">
                                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
                            </a>
                            <a href="<?php echo e(route('admin.users.edit',$u->id)); ?>" style="color:#D97706" title="Edit">
                                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>
                            </a>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($u->id !== Auth::id()): ?>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($u->isBanned()): ?>
                                <form action="<?php echo e(route('admin.users.unban',$u->id)); ?>" method="POST" style="display:inline"><?php echo csrf_field(); ?>
                                    <button type="submit" style="background:none;border:none;cursor:pointer;color:#059669" title="Aktifkan">
                                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
                                    </button>
                                </form>
                                <?php else: ?>
                                <button onclick="document.getElementById('ban-<?php echo e($u->id); ?>').style.display='flex'" style="background:none;border:none;cursor:pointer;color:#DC2626" title="Nonaktifkan">
                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>
                                </button>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                <form action="<?php echo e(route('admin.users.destroy',$u->id)); ?>" method="POST" style="display:inline" onsubmit="return confirm('Hapus user <?php echo e(addslashes($u->name)); ?> beserta semua datanya?')">
                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                    <button type="submit" style="background:none;border:none;cursor:pointer;color:#DC2626" title="Hapus">
                                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/></svg>
                                    </button>
                                </form>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </td>
                </tr>

                
                <tr style="display:none" id="ban-<?php echo e($u->id); ?>">
                    <td colspan="6" style="background:#FEF2F2;padding:1rem 1.25rem">
                        <form action="<?php echo e(route('admin.users.ban',$u->id)); ?>" method="POST" style="display:flex;align-items:flex-end;gap:.75rem;flex-wrap:wrap">
                            <?php echo csrf_field(); ?>
                            <div style="flex:1;min-width:200px">
                                <label style="font-size:.8rem;font-weight:600;color:#991B1B;display:block;margin-bottom:4px">Alasan penonaktifan <em>(opsional)</em></label>
                                <input type="text" name="reason" class="form-control" placeholder="Contoh: Melanggar ketentuan penggunaan" style="border-color:#FCA5A5">
                            </div>
                            <button type="submit" class="btn btn-danger btn-sm">Nonaktifkan</button>
                            <button type="button" onclick="document.getElementById('ban-<?php echo e($u->id); ?>').style.display='none'" class="btn btn-secondary btn-sm">Batal</button>
                        </form>
                    </td>
                </tr>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                <tr><td colspan="6" style="text-align:center;padding:3rem;color:#94A3B8">Tidak ada user ditemukan</td></tr>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </tbody>
        </table>
    </div>
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($users->hasPages()): ?>
    <div style="padding:1rem 1.5rem;border-top:1px solid #E2E8F0"><?php echo e($users->links()); ?></div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div>
</div>

<?php $__env->startPush('styles'); ?>
<style>
/* ===== DARK MODE FOR ADMIN USERS PAGE ===== */

.dark .page-title {
    color: #f1f5f9 !important;
}

.dark .page-subtitle {
    color: #cbd5e1 !important;
}

/* Stat Cards */
.dark [style*="background:#fff"] {
    background: #1e293b !important;
}

.dark [style*="background:#fff;border:1px solid #E2E8F0"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.dark [style*="border:1px solid #E2E8F0"] {
    border-color: #334155 !important;
}

/* Filter Card */
.dark .card {
    background: #1e293b !important;
    border-color: #334155 !important;
}

/* Form Labels */
.dark [style*="color:#64748B"][style*="display:block"] {
    color: #cbd5e1 !important;
}

.dark [style*="color:#64748B"] {
    color: #cbd5e1 !important;
}

/* Form Controls */
.dark .form-control {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

.dark .form-control::placeholder {
    color: #94a3b8 !important;
}

.dark .form-control:focus {
    border-color: #60a5fa !important;
    background: #334155 !important;
    color: #f1f5f9 !important;
}

/* Table Styling */
.dark .table-wrapper table thead {
    background: #0f172a !important;
}

.dark .table-wrapper table thead th {
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

.dark .table-wrapper table tbody tr {
    border-color: #334155 !important;
}

.dark .table-wrapper table tbody tr:hover {
    background: rgba(51, 65, 85, 0.3) !important;
}

.dark .table-wrapper table tbody td {
    border-color: #334155 !important;
}

/* Text colors in table */
.dark [style*="color:#1E293B"] {
    color: #f1f5f9 !important;
}

.dark [style*="color:#94A3B8"] {
    color: #cbd5e1 !important;
}

/* Badges and Tags */
.dark [style*="background:#EDE9FE"],
.dark [style*="background:#EDE9FE;color"] {
    background: rgba(124, 58, 237, 0.2) !important;
    color: #c4b5fd !important;
}

.dark [style*="background:#F1F5F9"],
.dark [style*="background:#F1F5F9;color"] {
    background: #334155 !important;
    color: #cbd5e1 !important;
}

.dark [style*="background:#D1FAE5"],
.dark [style*="background:#D1FAE5;color"] {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #86efac !important;
}

.dark [style*="background:#FEE2E2"],
.dark [style*="background:#FEE2E2;color"] {
    background: rgba(220, 38, 38, 0.2) !important;
    color: #fca5a5 !important;
}

/* Action Links */
.dark [style*="color:#1A56DB"] {
    color: #60a5fa !important;
}

.dark [style*="color:#D97706"] {
    color: #fcd34d !important;
}

.dark [style*="color:#059669"] {
    color: #86efac !important;
}

.dark [style*="color:#DC2626"] {
    color: #fca5a5 !important;
}

/* Ban Modal Row */
.dark [style*="background:#FEF2F2"] {
    background: rgba(127, 29, 29, 0.1) !important;
    border-color: #475569 !important;
}

.dark [style*="color:#991B1B"] {
    color: #fca5a5 !important;
}

.dark input[style*="border-color:#FCA5A5"] {
    border-color: #7f1d1d !important;
}

/* Button styling for dark mode handled by global CSS */

/* Pagination */
.dark [style*="border-top:1px solid #E2E8F0"] {
    border-top-color: #334155 !important;
}

/* ===== LIGHT MODE FALLBACK FOR ADMIN USERS PAGE ===== */

.light .page-title {
    color: #0f172a !important;
}

.light .page-subtitle {
    color: #64748b !important;
}

.light [style*="background:#fff"] {
    background: #ffffff !important;
}

.light .card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}

.light .form-control {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #1e293b !important;
}

.light .table-wrapper table thead {
    background: #f8fafc !important;
}

.light .table-wrapper table thead th {
    color: #64748b !important;
    border-color: #e2e8f0 !important;
}

.light .table-wrapper table tbody tr {
    border-color: #e2e8f0 !important;
}

.light .table-wrapper table tbody tr:hover {
    background: #f8fafc !important;
}

.light .table-wrapper table tbody td {
    border-color: #e2e8f0 !important;
}
</style>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/roky/projects/V1/resources/views/admin/users/index.blade.php ENDPATH**/ ?>