

<?php $__env->startSection('title', 'Dashboard Petugas'); ?>

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

<style>

.dashboard{
    width:100%;
}

/* WELCOME */

.welcome-card{
    position:relative;
    overflow:hidden;
    padding:45px;
    border-radius:32px;
    background:linear-gradient(
        135deg,
        #7c3aed,
        #2563eb
    );
    margin-bottom:35px;
    box-shadow:0 25px 50px rgba(37,99,235,.25);
}

.welcome-card::before{
    content:'';
    position:absolute;
    width:320px;
    height:320px;
    border-radius:50%;
    background:rgba(255,255,255,.08);
    top:-120px;
    right:-100px;
}

.welcome-card h1{
    font-size:42px;
    font-weight:800;
    color:white;
    margin-bottom:10px;
    position:relative;
    z-index:2;
}

.welcome-card p{
    color:#dbeafe;
    font-size:16px;
    position:relative;
    z-index:2;
}

/* STATS */

.stats{
    display:grid;
    grid-template-columns:
    repeat(auto-fit,minmax(220px,1fr));
    gap:22px;
    margin-bottom:35px;
}

.card-link{
    text-decoration:none;
}

.card-box{
    position:relative;
    overflow:hidden;
    background:rgba(255,255,255,.08);
    border:1px solid rgba(255,255,255,.08);
    backdrop-filter:blur(18px);
    border-radius:28px;
    padding:30px;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
    transition:.35s;
    cursor:pointer;
}

.card-box:hover{
    transform:translateY(-10px);
    box-shadow:
        0 20px 40px rgba(59,130,246,.25),
        0 10px 25px rgba(139,92,246,.2);
}

.card-box h5{
    font-size:16px;
    margin-bottom:18px;
    color:#cbd5e1;
}

.card-box h1{
    font-size:44px;
    font-weight:800;
    color:white;
}

.green{ color:#4ade80 !important; }
.blue{ color:#60a5fa !important; }
.yellow{ color:#facc15 !important; }
.cyan{ color:#22d3ee !important; }
.gray{ color:#e2e8f0 !important; }

/* HERO */

.hero{
    background:rgba(255,255,255,.08);
    border:1px solid rgba(255,255,255,.08);
    backdrop-filter:blur(18px);
    border-radius:32px;
    padding:45px;
    margin-bottom:35px;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
}

.hero-content{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:30px;
    flex-wrap:wrap;
}

.hero-text{
    flex:1;
}

.hero-text h1{
    color:white;
    font-size:42px;
    font-weight:800;
    margin-bottom:18px;
}

.hero-text p{
    color:#cbd5e1;
    line-height:1.8;
    margin-bottom:25px;
}

.btn-scan{
    display:inline-flex;
    align-items:center;
    gap:10px;
    text-decoration:none;
    padding:16px 24px;
    border-radius:18px;
    background:linear-gradient(
        135deg,
        #8b5cf6,
        #2563eb
    );
    color:white;
    font-weight:700;
    transition:.3s;
    box-shadow:0 10px 25px rgba(139,92,246,.35);
}

.btn-scan:hover{
    transform:translateY(-3px);
    color:white;
}

.hero-image img{
    width:250px;
    filter:drop-shadow(
        0 10px 25px rgba(0,0,0,.35)
    );
}

/* TABLE */

.table-card,
.chart-card{
    background:rgba(255,255,255,.08);
    border:1px solid rgba(255,255,255,.08);
    backdrop-filter:blur(18px);
    border-radius:30px;
    overflow:hidden;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
    margin-bottom:35px;
}

.table-header{
    padding:28px 35px;
    background:linear-gradient(
        135deg,
        #ef4444,
        #dc2626
    );
    color:white;
}

.table-header-flex{
    display:flex;
    justify-content:space-between;
    align-items:center;
    flex-wrap:wrap;
    gap:20px;
}

.table-title{
    font-size:28px;
    font-weight:800;
    margin-bottom:8px;
}

.table-subtitle{
    color:#fee2e2;
    font-size:14px;
}

.total-late{
    width:70px;
    height:70px;
    border-radius:20px;
    background:rgba(255,255,255,.15);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:28px;
    font-weight:800;
}

.chart-header{
    padding:22px 30px;
    background:linear-gradient(
        135deg,
        #2563eb,
        #7c3aed
    );
    color:white;
    font-size:22px;
    font-weight:700;
}

.table-header-green{
    padding:22px 30px;
    background:linear-gradient(
        135deg,
        #10b981,
        #059669
    );
    color:white;
    font-size:22px;
    font-weight:700;
}

.table-responsive{
    overflow-x:auto;
}

table{
    width:100%;
    border-collapse:collapse;
}

th{
    padding:20px;
    text-align:center;
    color:#e2e8f0;
    background:rgba(255,255,255,.04);
    font-size:14px;
}

td{
    padding:20px;
    text-align:center;
    border-bottom:
    1px solid rgba(255,255,255,.05);
    color:white;
    vertical-align:middle;
}

tr:hover{
    background:rgba(255,255,255,.03);
}

/* STUDENT */

.student-box{
    display:flex;
    align-items:center;
    gap:15px;
}

.student-avatar{
    width:48px;
    height:48px;
    border-radius:14px;
    background:linear-gradient(
        135deg,
        #8b5cf6,
        #2563eb
    );
    display:flex;
    align-items:center;
    justify-content:center;
    color:white;
    font-weight:800;
}

.student-name{
    font-weight:700;
    color:white;
    margin-bottom:4px;
}

.student-nis{
    font-size:12px;
    color:#94a3b8;
}

/* BOOK */

.book-box{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:10px;
    font-weight:600;
}

/* BADGE */

.badge-danger,
.badge-success,
.badge-warning{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:10px 16px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
}

.badge-danger{
    background:rgba(239,68,68,.18);
    color:#fca5a5;
}

.badge-success{
    background:rgba(34,197,94,.18);
    color:#86efac;
}

.badge-warning{
    background:rgba(245,158,11,.18);
    color:#fcd34d;
}

/* BUTTON */

.btn-selesai{
    border:none;
    padding:10px 16px;
    border-radius:12px;
    background:linear-gradient(
        135deg,
        #10b981,
        #059669
    );
    color:white;
    font-size:12px;
    font-weight:700;
    cursor:pointer;
    transition:.3s;
}

.btn-selesai:hover{
    transform:translateY(-2px);
}

/* EMPTY */

.empty-box{
    padding:60px 20px;
    text-align:center;
    color:#cbd5e1;
}

.empty-box i{
    font-size:60px;
    color:#4ade80;
    margin-bottom:20px;
}

.empty-box h3{
    color:white;
    margin-bottom:10px;
}

/* CHART */

.chart-body{
    padding:30px;
}

@media(max-width:992px){

    .hero-content{
        flex-direction:column;
    }

    .hero-image img{
        width:180px;
    }

    .student-box{
        flex-direction:column;
        text-align:center;
    }

}

</style>

<div class="dashboard">

    <!-- WELCOME -->

    <div class="welcome-card">

        <h1>
            👋 Selamat Datang,
            <?php echo e(session('nama_petugas')); ?>

        </h1>

        <p>
            Sistem Perpustakaan Digital Modern
            untuk mengelola buku, siswa,
            dan transaksi perpustakaan lebih cepat.
        </p>

    </div>

    <!-- STATISTIK -->

    <div class="stats">

        <a href="/buku" class="card-link">
            <div class="card-box">
                <h5 class="green">📚 Total Buku</h5>
                <h1><?php echo e($total_buku); ?></h1>
            </div>
        </a>

        <a href="/siswa" class="card-link">
            <div class="card-box">
                <h5 class="blue">🎓 Total Siswa</h5>
                <h1><?php echo e($total_siswa); ?></h1>
            </div>
        </a>

        <a href="/transaksi" class="card-link">
            <div class="card-box">
                <h5 class="yellow">🔄 Total Transaksi</h5>
                <h1><?php echo e($total_transaksi); ?></h1>
            </div>
        </a>

        <a href="/transaksi?status=dipinjam" class="card-link">
            <div class="card-box">
                <h5 class="cyan">📖 Dipinjam</h5>
                <h1><?php echo e($dipinjam); ?></h1>
            </div>
        </a>

        <a href="/transaksi?status=dikembalikan" class="card-link">
            <div class="card-box">
                <h5 class="gray">✅ Dikembalikan</h5>
                <h1><?php echo e($dikembalikan); ?></h1>
            </div>
        </a>

        <a href="/transaksi?status=terlambat" class="card-link">
            <div class="card-box">
                <h5 style="color:#f87171;">⏰ Terlambat</h5>
                <h1><?php echo e($terlambat); ?></h1>
            </div>
        </a>

    </div>

    <!-- HERO -->

    <div class="hero">

        <div class="hero-content">

            <div class="hero-text">

                <h1>
                    Kelola Perpustakaan
                    Lebih Modern 🚀
                </h1>

                <p>
                    Pantau data buku,
                    transaksi peminjaman,
                    keterlambatan,
                    dan scan QR siswa
                    secara real-time.
                </p>

                <a href="/scan" class="btn-scan">
                    📷 Scan Siswa Sekarang
                </a>

            </div>

            <div class="hero-image">

                <img src="https://cdn-icons-png.flaticon.com/512/3135/3135755.png">

            </div>

        </div>

    </div>

    <!-- PEMINJAMAN -->

    <div class="chart-card">

        <div class="chart-header">

            📖 Peminjaman Buku Terbaru

        </div>

        <div class="chart-body">

            <table>

                <thead>

                    <tr>

                        <th>No</th>
                        <th>Nama Siswa</th>
                        <th>Buku</th>
                        <th>Tanggal Pinjam</th>
                        <th>Jatuh Tempo</th>
                        <th>Status</th>

                    </tr>

                </thead>

                <tbody>

                    <?php $__empty_1 = true; $__currentLoopData = $transaksi_terbaru; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                    <tr>

                        <td><?php echo e($k + 1); ?></td>

                        <td>

                            <div class="student-box">

                                <div class="student-avatar">

                                    <?php echo e(strtoupper(substr($t->siswa->nama_siswa ?? 'S',0,1))); ?>


                                </div>

                                <div>

                                    <div class="student-name">

                                        <?php echo e($t->siswa->nama_siswa ?? '-'); ?>


                                    </div>

                                    <div class="student-nis">

                                        NIS :
                                        <?php echo e($t->siswa->nis ?? '-'); ?>


                                    </div>

                                </div>

                            </div>

                        </td>

                        <td>

                            <div class="book-box">

                                📚
                                <?php echo e($t->buku->judul_buku ?? '-'); ?>


                            </div>

                        </td>

                        <td>

                            <?php echo e(\Carbon\Carbon::parse($t->tanggal_pinjam)->format('d M Y')); ?>


                        </td>

                        <td>

                            <?php echo e(\Carbon\Carbon::parse($t->tanggal_kembali)->format('d M Y')); ?>


                        </td>

                        <td>

                            <?php if($t->status == 'terlambat'): ?>

                                <span class="badge-danger">

                                    ⏰ Terlambat

                                </span>

                            <?php elseif($t->status == 'dipinjam'): ?>

                                <span class="badge-warning">

                                    📖 Dipinjam

                                </span>

                            <?php else: ?>

                                <span class="badge-success">

                                    ✅ Dikembalikan

                                </span>

                            <?php endif; ?>

                        </td>

                    </tr>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <tr>

                        <td colspan="6">

                            <div class="empty-box">

                                <i class="fa-solid fa-book"></i>

                                <h3>
                                    Belum Ada Peminjaman
                                </h3>

                                <p>
                                    Data peminjaman buku akan muncul di sini
                                </p>

                            </div>

                        </td>

                    </tr>

                    <?php endif; ?>

                </tbody>

            </table>

        </div>

    </div>

    <!-- KETERLAMBATAN -->

    <div class="table-card">

        <div class="table-header">

            <div class="table-header-flex">

                <div>

                    <div class="table-title">

                        🚨 Keterlambatan Terbaru

                    </div>

                    <div class="table-subtitle">

                        Monitoring siswa yang terlambat
                        mengembalikan buku perpustakaan

                    </div>

                </div>

                <div class="total-late">

                    <?php echo e($terlambat); ?>


                </div>

            </div>

        </div>

        <div class="table-responsive">

            <table>

                <thead>

                    <tr>

                        <th>No</th>
                        <th>Siswa</th>
                        <th>Buku</th>
                        <th>Tanggal Pinjam</th>
                        <th>Jatuh Tempo</th>
                        <th>Status Pengembalian</th>
                        <th>Status Sanksi</th>
                        <th>Aksi</th>

                    </tr>

                </thead>

                <tbody>

                    <?php $__empty_1 = true; $__currentLoopData = $keterlambatan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                    <tr>

                        <td><?php echo e($k + 1); ?></td>

                        <td>

                            <div class="student-box">

                                <div class="student-avatar">

                                    <?php echo e(strtoupper(substr($t->siswa->nama_siswa ?? 'S',0,1))); ?>


                                </div>

                                <div>

                                    <div class="student-name">

                                        <?php echo e($t->siswa->nama_siswa ?? '-'); ?>


                                    </div>

                                    <div class="student-nis">

                                        NIS :
                                        <?php echo e($t->siswa->nis ?? '-'); ?>


                                    </div>

                                </div>

                            </div>

                        </td>

                        <td>

                            <div class="book-box">

                                📚
                                <?php echo e($t->buku->judul_buku ?? '-'); ?>


                            </div>

                        </td>

                        <td>

                            <?php echo e(\Carbon\Carbon::parse($t->tanggal_pinjam)->format('d M Y')); ?>


                        </td>

                        <td>

                            <span style="color:#fca5a5;font-weight:700;">

                                <?php echo e(\Carbon\Carbon::parse($t->tanggal_kembali)->format('d M Y')); ?>


                            </span>

                        </td>

                        <td>

                            <span class="badge-danger">

                                ⏰ Terlambat

                            </span>

                        </td>

                        <td>

                            <?php if($t->status_sanksi == 'selesai'): ?>

                                <span class="badge-success">

                                    ✅ Selesai

                                </span>

                            <?php else: ?>

                                <span class="badge-warning">

                                    ⌛ Belum Selesai

                                </span>

                            <?php endif; ?>

                        </td>

                        <td>

                            <?php if($t->status_sanksi != 'selesai'): ?>

                                <form action="<?php echo e(route('sanksi.selesai', $t->id_transaksi)); ?>"
                                      method="POST">

                                    <?php echo csrf_field(); ?>

                                    <button type="submit"
                                            class="btn-selesai">

                                        ✔ Selesai

                                    </button>

                                </form>

                            <?php else: ?>

                                <span class="badge-success">

                                    ✔ Sudah

                                </span>

                            <?php endif; ?>

                        </td>

                    </tr>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <tr>

                        <td colspan="8">

                            <div class="empty-box">

                                <i class="fa-solid fa-circle-check"></i>

                                <h3>

                                    Tidak Ada Keterlambatan

                                </h3>

                                <p>

                                    Semua transaksi pengembalian
                                    berjalan dengan baik

                                </p>

                            </div>

                        </td>

                    </tr>

                    <?php endif; ?>

                </tbody>

            </table>

        </div>

    </div>

    <!-- TOP BUKU -->

    <div class="chart-card">

        <div class="chart-header">

            📚 Top Buku Populer

        </div>

        <div class="chart-body">

            <table>

                <thead>

                    <tr>

                        <th>No</th>
                        <th>Judul Buku</th>
                        <th>Total Dipinjam</th>

                    </tr>

                </thead>

                <tbody>

                    <?php $__empty_1 = true; $__currentLoopData = $top_buku; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                    <tr>

                        <td><?php echo e($k + 1); ?></td>

                        <td>

                            <?php echo e($b->buku->judul_buku ?? '-'); ?>


                        </td>

                        <td>

                            <?php echo e($b->total); ?>x

                        </td>

                    </tr>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <tr>

                        <td colspan="3">

                            <div class="empty-box">

                                Tidak ada data buku populer

                            </div>

                        </td>

                    </tr>

                    <?php endif; ?>

                </tbody>

            </table>

        </div>

    </div>

    <!-- TOP SISWA -->

    <div class="chart-card">

        <div class="table-header-green">

            🎓 Top Siswa Peminjam

        </div>

        <div class="chart-body">

            <table>

                <thead>

                    <tr>

                        <th>No</th>
                        <th>Nama Siswa</th>
                        <th>Total Pinjam</th>

                    </tr>

                </thead>

                <tbody>

                    <?php $__empty_1 = true; $__currentLoopData = $siswa_populer; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                    <tr>

                        <td><?php echo e($k + 1); ?></td>

                        <td>

                            <?php echo e($s->siswa->nama_siswa ?? '-'); ?>


                        </td>

                        <td>

                            <?php echo e($s->total); ?>x

                        </td>

                    </tr>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <tr>

                        <td colspan="3">

                            <div class="empty-box">

                                Tidak ada data siswa populer

                            </div>

                        </td>

                    </tr>

                    <?php endif; ?>

                </tbody>

            </table>

        </div>

    </div>

    <!-- GRAFIK -->

    <div class="chart-card">

        <div class="chart-header">

            📈 Grafik Transaksi

        </div>

        <div class="chart-body">

            <canvas id="grafikTransaksi"></canvas>

        </div>

    </div>

</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script>

const ctx =
document.getElementById('grafikTransaksi');

new Chart(ctx, {

    type:'line',

    data:{

        labels:[

            <?php $__currentLoopData = $grafik; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $g): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                '<?php echo e($g->tanggal); ?>',

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        ],

        datasets:[{

            label:'Jumlah Transaksi',

            data:[

                <?php $__currentLoopData = $grafik; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $g): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                    <?php echo e($g->total); ?>,

                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            ],

            borderWidth:3,
            tension:.4,
            fill:true

        }]

    }

});

</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.petugas', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\aplikasi-perpustakaan\resources\views/dashboard/petugas.blade.php ENDPATH**/ ?>