

<?php $__env->startSection('title', 'Review - ' . $book->judul); ?>
<?php $__env->startSection('page-title', 'Review Buku'); ?>

<?php $__env->startSection('content'); ?>

<div class="row mb-4">
    <div class="col-12">
        <div class="book-header-card">
            <div class="row align-items-center">
                <div class="col-md-2 text-center">
                    <?php if($book->gambar): ?>
                        <img src="<?php echo e(asset('storage/' . $book->gambar)); ?>" alt="<?php echo e($book->judul); ?>" class="book-cover">
                    <?php else: ?>
                        <div class="book-cover-placeholder">
                            <i class="fas fa-book fa-3x"></i>
                        </div>
                    <?php endif; ?>
                </div>
                <div class="col-md-7">
                    <h3 class="mb-2"><?php echo e($book->judul); ?></h3>
                    <p class="text-muted mb-1"><i class="fas fa-user me-2"></i><?php echo e($book->nama_pengarang ?? '-'); ?></p>
                    <p class="text-muted mb-0"><i class="fas fa-building me-2"></i><?php echo e($book->penerbit ?? '-'); ?></p>
                </div>
                <div class="col-md-3 text-center">
                    <div class="rating-summary">
                        <div class="avg-rating-display"><?php echo e(number_format($avgRating ?? 0, 1)); ?></div>
                        <div class="stars-display mb-2">
                            <?php for($i = 1; $i <= 5; $i++): ?>
                                <?php if($i <= ($avgRating ?? 0)): ?>
                                    <i class="fas fa-star text-warning"></i>
                                <?php else: ?>
                                    <i class="far fa-star text-warning"></i>
                                <?php endif; ?>
                            <?php endfor; ?>
                        </div>
                        <p class="text-muted mb-0"><?php echo e($totalReviews); ?> <?php echo e(Str::plural('Review', $totalReviews)); ?></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="row mb-4">
    <div class="col-12">
        <div class="stat-card">
            <h5 class="mb-3"><i class="fas fa-chart-bar me-2"></i>Distribusi Rating</h5>
            <?php $__currentLoopData = $ratingDistribution; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rating => $count): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="rating-bar-container mb-2">
                <div class="rating-bar-label"><?php echo e($rating); ?> <i class="fas fa-star text-warning"></i></div>
                <div class="rating-bar-track">
                    <div class="rating-bar-fill" style="width: <?php echo e($totalReviews > 0 ? ($count / $totalReviews * 100) : 0); ?>%"></div>
                </div>
                <div class="rating-bar-count"><?php echo e($count); ?></div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>
</div>


<div class="row mb-3">
    <div class="col-md-3">
        <select class="form-select" id="ratingFilter" onchange="window.location.href='<?php echo e(route('review.book', $book->id_buku)); ?>?rating=' + this.value + '&search=<?php echo e(request('search')); ?>'">
            <option value="">Semua Rating</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); ?> Bintang</option>
            <?php endfor; ?>
        </select>
    </div>
    <div class="col-md-9">
        <form action="<?php echo e(route('review.book', $book->id_buku)); ?>" method="GET" class="d-flex">
            <input type="hidden" name="rating" value="<?php echo e(request('rating')); ?>">
            <input type="text" class="form-control me-2" name="search" placeholder="Cari nama reviewer..." value="<?php echo e(request('search')); ?>">
            <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
        </form>
    </div>
</div>


<div class="row">
    <?php $__empty_1 = true; $__currentLoopData = $reviews; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $review): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
    <div class="col-12 mb-3">
        <div class="review-card">
            <div class="review-header">
                <div class="reviewer-info">
                    <div class="reviewer-avatar">
                        <?php if($review->user && $review->user->foto_profil): ?>
                            <img src="<?php echo e(asset('storage/' . $review->user->foto_profil)); ?>" alt="<?php echo e($review->user->nama); ?>">
                        <?php else: ?>
                            <i class="fas fa-user"></i>
                        <?php endif; ?>
                    </div>
                    <div>
                        <h6 class="mb-0"><?php echo e($review->user->nama ?? 'Anonymous'); ?></h6>
                        <small class="text-muted">Review #<?php echo e($review->id_ulasan); ?></small>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-2">
                    <div class="review-rating">
                        <?php for($i = 1; $i <= 5; $i++): ?>
                            <?php if($i <= $review->rating): ?>
                                <i class="fas fa-star text-warning"></i>
                            <?php else: ?>
                                <i class="far fa-star text-warning"></i>
                            <?php endif; ?>
                        <?php endfor; ?>
                    </div>
                    <form action="<?php echo e(route('pengelolaan.review.destroy', $review->id_ulasan)); ?>" method="POST" 
                          onsubmit="return confirm('Yakin ingin menghapus review ini?')">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <button type="submit" class="btn btn-danger btn-sm">
                            <i class="fas fa-trash"></i>
                        </button>
                    </form>
                </div>
            </div>
            <div class="review-comment">
                <?php echo e($review->komentar); ?>

            </div>
        </div>
    </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
    <div class="col-12">
        <div class="stat-card text-center py-5">
            <i class="fas fa-comments fa-3x text-muted mb-3"></i>
            <p class="text-muted">Tidak ada review yang ditemukan</p>
        </div>
    </div>
    <?php endif; ?>
</div>


<?php if($reviews->hasPages()): ?>
<div class="row mt-4">
    <div class="col-12">
        <?php echo e($reviews->appends(request()->query())->links()); ?>

    </div>
</div>
<?php endif; ?>


<div class="row mt-3">
    <div class="col-12">
        <a href="<?php echo e(route('pengelolaan.review')); ?>" class="btn btn-secondary">
            <i class="fas fa-arrow-left me-2"></i>Kembali
        </a>
    </div>
</div>


<?php if($book->deskripsi): ?>
<div class="row mt-4">
    <div class="col-12">
        <div class="stat-card">
            <h5 class="mb-3"><i class="fas fa-align-left me-2"></i>Tentang Buku Ini</h5>
            <p class="text-muted mb-0" style="line-height: 1.8; white-space: pre-wrap;"><?php echo e($book->deskripsi); ?></p>
        </div>
    </div>
</div>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
<style>
.book-header-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 2rem;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.book-cover {
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.book-cover-placeholder {
    width: 120px;
    height: 160px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.rating-summary {
    background: rgba(255,255,255,0.2);
    padding: 1.5rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.avg-rating-display {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.stars-display i {
    font-size: 1.2rem;
}

.rating-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rating-bar-label {
    min-width: 80px;
    font-weight: 500;
}

.rating-bar-track {
    flex: 1;
    height: 25px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
}

.rating-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
}

.rating-bar-count {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
}

.review-card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
}

.review-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.reviewer-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reviewer-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    overflow: hidden;
}

.reviewer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.review-rating i {
    font-size: 1.1rem;
}

.review-comment {
    color: #555;
    line-height: 1.6;
    font-size: 0.95rem;
}
</style>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\hizkia\Desktop\TUBES_MSBD\Perpustakaan-SMAN-1-Pangururan\resources\views/admin/book_reviews.blade.php ENDPATH**/ ?>