<?php $__env->startSection('title', 'KYC Documents'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col"><h2 class="page-title">KYC Documents</h2></div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="card mb-3">
        <div class="card-body">
            <form method="GET" class="row g-3">
                <div class="col-md-4">
                    <select name="status" class="form-select">
                        <option value="">All Statuses</option>
                        <?php $__currentLoopData = ['pending','approved','rejected']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($s); ?>" <?php echo e(request('status')==$s?'selected':''); ?>><?php echo e(ucfirst($s)); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-md-4">
                    <select name="type" class="form-select">
                        <option value="">All Types</option>
                        <?php $__currentLoopData = ['national_id','passport','drivers_license','business_registration','utility_bill','cac_certificate','other']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($t); ?>" <?php echo e(request('type')==$t?'selected':''); ?>><?php echo e(ucwords(str_replace('_',' ',$t))); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-md-4 d-flex gap-2">
                    <button type="submit" class="btn btn-primary">Filter</button>
                    <a href="<?php echo e(route('admin.kyc.index')); ?>" class="btn btn-outline-secondary">Clear</a>
                </div>
            </form>
        </div>
    </div>

    <div class="card">
        <div class="card-header"><h3 class="card-title">All KYC Submissions (<?php echo e($documents->total()); ?>)</h3></div>
        <div class="table-responsive">
            <table class="table table-vcenter card-table">
                <thead>
                    <tr><th>Vendor</th><th>Document Type</th><th>Status</th><th>Submitted</th><th>Reviewed By</th><th>Actions</th></tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $documents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td>
                            <div class="fw-medium"><?php echo e($doc->vendor?->business_name); ?></div>
                            <div class="text-muted small"><?php echo e($doc->vendor?->user?->email); ?></div>
                        </td>
                        <td class="text-capitalize"><?php echo e(str_replace('_',' ',$doc->document_type)); ?></td>
                        <td>
                            <?php $kc=['pending'=>'warning','approved'=>'success','rejected'=>'danger']; ?>
                            <span class="badge bg-<?php echo e($kc[$doc->status]??'secondary'); ?>-lt text-capitalize"><?php echo e($doc->status); ?></span>
                        </td>
                        <td><?php echo e($doc->created_at->format('d M Y')); ?></td>
                        <td><?php echo e($doc->reviewer?->name ?? '—'); ?></td>
                        <td>
                            <div class="d-flex gap-1">
                                <a href="<?php echo e(route('admin.kyc.show', $doc->vendor)); ?>" class="btn btn-sm btn-outline-secondary">View Vendor</a>
                                <?php if($doc->status === 'pending'): ?>
                                <form action="<?php echo e(route('admin.kyc.document.approve', $doc)); ?>" method="POST">
                                    <?php echo csrf_field(); ?> <button class="btn btn-sm btn-success">Approve</button>
                                </form>
                                <button class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#rejectDoc<?php echo e($doc->id); ?>">Reject</button>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <div class="modal modal-blur fade" id="rejectDoc<?php echo e($doc->id); ?>" tabindex="-1">
                        <div class="modal-dialog modal-sm modal-dialog-centered"><div class="modal-content">
                            <form action="<?php echo e(route('admin.kyc.document.reject', $doc)); ?>" method="POST"><?php echo csrf_field(); ?>
                                <div class="modal-header"><h5 class="modal-title">Reject Document</h5></div>
                                <div class="modal-body"><textarea name="remarks" class="form-control" rows="3" placeholder="Reason..." required></textarea></div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
                                    <button type="submit" class="btn btn-danger btn-sm">Reject</button>
                                </div>
                            </form>
                        </div></div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="6" class="text-center text-muted py-4">No KYC documents found</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="card-footer d-flex align-items-center"><?php echo e($documents->links()); ?></div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/dev13codebuzzers/public_html/yamee/resources/views/admin/kyc/index.blade.php ENDPATH**/ ?>