

<?php $__env->startSection('title', 'Product Reviews'); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-page-header">
    <h1>Product Reviews</h1>
</div>

<!-- Statistics Cards -->
<div class="row g-4 mb-4">
    <div class="col-md-6 col-lg-3">
        <div class="kpi-card">
            <div class="kpi-card-icon kpi-card-icon-primary">
                <i class="bi bi-list-stars"></i>
            </div>
            <div class="kpi-card-content-wrapper">
                <div class="kpi-card-value"><?php echo e($totalReviews); ?></div>
                <div class="kpi-card-label">Total Reviews</div>
            </div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="kpi-card">
            <div class="kpi-card-icon kpi-card-icon-success">
                <i class="bi bi-stars"></i>
            </div>
            <div class="kpi-card-content-wrapper">
                <div class="kpi-card-value"><?php echo e($approvedReviews); ?></div>
                <div class="kpi-card-label">Approved</div>
            </div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="kpi-card">
            <div class="kpi-card-icon kpi-card-icon-warning">
                <i class="bi bi-star-half"></i>
            </div>
            <div class="kpi-card-content-wrapper">
                <div class="kpi-card-value"><?php echo e($pendingReviews); ?></div>
                <div class="kpi-card-label">Pending</div>
            </div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="kpi-card">
            <div class="kpi-card-icon kpi-card-icon-info">
                <i class="bi bi-star"></i>
            </div>
            <div class="kpi-card-content-wrapper">
                <div class="kpi-card-value"><?php echo e(number_format($avgRating ?? 0, 1)); ?></div>
                <div class="kpi-card-label">Avg Rating</div>
            </div>
        </div>
    </div>
</div>

<!-- Filters -->
<div class="admin-card mb-4">
    <div class="card-body">
        <form method="GET" action="<?php echo e(route('admin.reviews.index')); ?>" class="row g-3">
            <div class="col-md-2 col-lg-3">
                <label for="search" class="admin-form-label">Search</label>
                <input type="text" class="admin-form-control form-control" id="search" name="search" 
                       value="<?php echo e(request('search')); ?>" placeholder="Search reviews...">
            </div>
            <div class="col-md-2">
                <label for="product_id" class="admin-form-label">Product</label>
                <select class="admin-form-control form-select" id="product_id" name="product_id">
                    <option value="">All Products</option>
                    <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($product->id); ?>" <?php echo e(request('product_id') == $product->id ? 'selected' : ''); ?>>
                            <?php echo e($product->name); ?>

                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-md-2">
                <label for="is_approved" class="admin-form-label">Status</label>
                <select class="admin-form-control form-select" id="is_approved" name="is_approved">
                    <option value="">All</option>
                    <option value="1" <?php echo e(request('is_approved') === '1' ? 'selected' : ''); ?>>Approved</option>
                    <option value="0" <?php echo e(request('is_approved') === '0' ? 'selected' : ''); ?>>Pending</option>
                </select>
            </div>
            <div class="col-md-2">
                <label for="rating" class="admin-form-label">Rating</label>
                <select class="admin-form-control form-select" id="rating" name="rating">
                    <option value="">All</option>
                    <?php for($i = 5; $i >= 1; $i--): ?>
                        <option value="<?php echo e($i); ?>" <?php echo e(request('rating') == $i ? 'selected' : ''); ?>>
                            <?php echo e($i); ?> Star<?php echo e($i > 1 ? 's' : ''); ?>

                        </option>
                    <?php endfor; ?>
                </select>
            </div>
            <div class="col-md-3 d-flex align-items-end gap-1">
                <button type="submit" class="admin-btn-primary">
                    <i class="bi bi-search"></i> Filter
                </button>
                <a href="<?php echo e(route('admin.reviews.index')); ?>"title="Reset" class="btn btn-outline-secondary" >
                                <i class="bi bi-arrow-clockwise"></i>
                </a>
                <a href="<?php echo e(route('admin.reviews.export-csv', request()->query())); ?>" class="btn btn-outline-secondary" style="background: #10b981; color:#fff">
                    <i class="bi bi-download"></i> Export CSV
                </a>
            </div>
        </form>
    </div>
</div>

    <!-- Reviews Table -->
    <div class="admin-table-card">
        <div class="card-body">
            <?php if($reviews->count() > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover admin-table">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Product</th>
                                <th>User</th>
                                <th>Rating</th>
                                <th>Title</th>
                                <th>Review</th>
                                <th>Status</th>
                                <th>Date</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $reviews; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $review): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($review->id); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('product.show', $review->product->slug)); ?>" target="_blank">
                                            <?php echo e(Str::limit($review->product->name, 30)); ?>

                                        </a>
                                    </td>
                                    <td>
                                        <?php echo e($review->user ? $review->user->name : 'Anonymous'); ?>

                                        <?php if($review->order_id): ?>
                                            <span class="badge-modern badge-modern-success ms-1">
                                                <i class="bi bi-check-circle"></i> Verified
                                            </span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <?php if (isset($component)) { $__componentOriginalfa87e49ca3cdf62358bbc468aaf3394b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalfa87e49ca3cdf62358bbc468aaf3394b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.star-rating','data' => ['rating' => $review->rating,'size' => 'sm']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('star-rating'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['rating' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($review->rating),'size' => 'sm']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalfa87e49ca3cdf62358bbc468aaf3394b)): ?>
<?php $attributes = $__attributesOriginalfa87e49ca3cdf62358bbc468aaf3394b; ?>
<?php unset($__attributesOriginalfa87e49ca3cdf62358bbc468aaf3394b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalfa87e49ca3cdf62358bbc468aaf3394b)): ?>
<?php $component = $__componentOriginalfa87e49ca3cdf62358bbc468aaf3394b; ?>
<?php unset($__componentOriginalfa87e49ca3cdf62358bbc468aaf3394b); ?>
<?php endif; ?>
                                    </td>
                                    <td><?php echo e(Str::limit($review->title ?? 'N/A', 30)); ?></td>
                                    <td><?php echo e(Str::limit($review->body ?? 'N/A', 50)); ?></td>
                                    <td>
                                        <?php if($review->is_approved): ?>
                                            <span class="badge-modern badge-modern-success">
                                                <i class="bi bi-check-circle"></i> Approved
                                            </span>
                                        <?php else: ?>
                                            <span class="badge-modern badge-modern-warning">
                                                <i class="bi bi-clock"></i> Pending
                                            </span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($review->created_at->format('M d, Y')); ?></td>
                                    <td>
                                        <div class="d-flex gap-2">
                                            <?php if(!$review->is_approved): ?>
                                                <button class="admin-action-btn admin-action-btn-sm approve-btn" 
                                                        style="background: #10b981; color: white; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0;"
                                                        data-review-id="<?php echo e($review->id); ?>"
                                                        data-action="approve"
                                                        title="Approve">
                                                    <i class="bi bi-check-circle"></i>
                                                </button>
                                            <?php else: ?>
                                                <button class="admin-action-btn admin-action-btn-sm approve-btn" 
                                                        data-review-id="<?php echo e($review->id); ?>"
                                                        style="background: #f59e0b; color: white; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0;"
                                                        data-action="unapprove"
                                                        title="Unapprove">
                                                    <i class="bi bi-x-circle"></i>
                                                </button>
                                            <?php endif; ?>
                                            <button class="btn btn-danger delete-btn" 
                                                    data-review-id="<?php echo e($review->id); ?>"
                                                    style="background: #ef4444; height: -webkit-fill-available; color: white; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0;"
                                                    title="Delete">
                                                <i class="bi bi-trash"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>

                <!-- Pagination - Right Aligned -->
                <?php if($reviews->hasPages()): ?>
                <div class="pagination-wrapper mt-4">
                    <div class="d-flex justify-content-end align-items-center gap-3 flex-wrap">
                        <div class="pagination-info-text">
                            Showing <strong><?php echo e($reviews->firstItem() ?? 0); ?></strong>–<strong><?php echo e($reviews->lastItem() ?? 0); ?></strong> 
                            of <strong><?php echo e($reviews->total()); ?></strong> reviews
                        </div>
                        <div class="pagination-controls">
                            <?php echo e($reviews->links('vendor.pagination.admin-categories')); ?>

                        </div>
                    </div>
                </div>
                <?php endif; ?>
            <?php else: ?>
                <div class="admin-empty-state">
                    <i class="bi bi-star"></i>
                    <h3>No Reviews Found</h3>
                    <p>No reviews match your current filters.</p>
                </div>
            <?php endif; ?>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="<?php echo e(asset('js/admin-reviews.js')); ?>"></script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/shaa_jewels/live/resources/views/admin/reviews/index.blade.php ENDPATH**/ ?>