<?php $__env->startSection('title', 'Analyses | Smart Dermatology'); ?>
<?php $__env->startSection('page_title', 'Skin Analyses'); ?>
<?php $__env->startSection('page_subtitle', 'Review uploaded images, predicted diseases, and the users behind them.'); ?>

<?php $__env->startPush('styles'); ?>
    <style>
        .analysis-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 16px; }
    </style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
    <div class="card panel-card p-4">
        <form method="GET" action="<?php echo e(route('admin.analyses')); ?>" class="row g-3 mb-4">
            <div class="col-md-4">
                <label class="form-label fw-semibold">Search</label>
                <input type="text" name="search" class="form-control" value="<?php echo e(request('search')); ?>" placeholder="User, email, filename, disease">
            </div>
            <div class="col-md-3">
                <label class="form-label fw-semibold">Disease</label>
                <select name="disease" class="form-select">
                    <option value="">All diseases</option>
                    <?php $__currentLoopData = $diseases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $disease): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($disease); ?>" <?php if(request('disease') === $disease): echo 'selected'; endif; ?>><?php echo e(str_replace('_', ' ', $disease)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-md-2">
                <label class="form-label fw-semibold">From</label>
                <input type="date" name="date_from" class="form-control" value="<?php echo e(request('date_from')); ?>">
            </div>
            <div class="col-md-2">
                <label class="form-label fw-semibold">To</label>
                <input type="date" name="date_to" class="form-control" value="<?php echo e(request('date_to')); ?>">
            </div>
            <div class="col-md-1 d-flex align-items-end">
                <button type="submit" class="btn btn-dark w-100">Go</button>
            </div>
            <div class="col-12 d-flex justify-content-end">
                <a href="<?php echo e(route('admin.analyses')); ?>" class="btn btn-outline-secondary rounded-pill">Reset Filters</a>
            </div>
        </form>

        <div class="table-responsive">
            <table class="table align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th>Image</th>
                        <th>User</th>
                        <th>Filename</th>
                        <th>Disease</th>
                        <th>Confidence</th>
                        <th>Analyzed At</th>
                        <th class="text-end">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $analyses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $analysis): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><img src="<?php echo e(asset($analysis->image_path)); ?>" alt="Analyzed image" class="analysis-thumb"></td>
                            <td>
                                <div class="fw-semibold"><?php echo e($analysis->user->name); ?></div>
                                <div class="small text-muted"><?php echo e($analysis->user->email); ?></div>
                            </td>
                            <td><?php echo e($analysis->original_filename); ?></td>
                            <td class="text-capitalize"><?php echo e(str_replace('_', ' ', $analysis->disease)); ?></td>
                            <td><?php echo e(number_format($analysis->confidence * 100, 2)); ?>%</td>
                            <td><?php echo e($analysis->created_at?->format('d M Y h:i A')); ?></td>
                            <td class="text-end">
                                <form action="<?php echo e(route('admin.analyses.destroy', $analysis)); ?>" method="POST" onsubmit="return confirm('Delete analysis entry for <?php echo e(addslashes($analysis->original_filename)); ?>? This will also remove the saved image file.');">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-danger rounded-pill">Delete</button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="7" class="text-center text-muted py-5">No analyses have been recorded yet.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <?php if($analyses->hasPages()): ?>
            <div class="mt-4">
                <?php echo e($analyses->links()); ?>

            </div>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\Doodles Tech\Products\FYP\FYP\skin-analysis\resources\views/admin/pages/analyses.blade.php ENDPATH**/ ?>