<?php $__env->startSection('title', 'Dashboard'); ?>
<?php $__env->startSection('subtitle', 'Selamat datang kembali, ' . (auth()->user()->name ?? 'Admin')); ?>

<?php $__env->startSection('extra-style'); ?>
<style>
/* Login Log Carousel */
.login-carousel-wrap{ position:relative; overflow:hidden; }
.login-carousel{ display:flex; gap:16px; transition:transform .5s cubic-bezier(.4,0,.2,1); will-change:transform; }
.login-card{ min-width:260px; max-width:260px; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px; box-shadow:var(--shadow); flex-shrink:0; position:relative; overflow:hidden; }
.login-card::before{ content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius:14px 14px 0 0; }
.login-card.success::before{ background:var(--brand); }
.login-card.failed::before{ background:#e25c4f; }
.login-card-head{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.login-card-avatar{ width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.85rem; flex-shrink:0; color:#fff; }
.login-card.success .login-card-avatar{ background:var(--brand); }
.login-card.failed .login-card-avatar{ background:#e25c4f; }
.login-card-name{ font-weight:700; font-size:.88rem; line-height:1.2; }
.login-card-email{ font-size:.72rem; color:var(--text-muted); }
.login-card-status{ display:inline-flex; align-items:center; gap:5px; font-size:.68rem; font-weight:700; text-transform:uppercase; padding:3px 10px; border-radius:99px; margin-bottom:10px; }
.login-card.success .login-card-status{ background:#dcf3ec; color:#0d6e57; }
.login-card.failed .login-card-status{ background:#fde8e7; color:#b3413c; }
.login-card-meta{ display:flex; flex-direction:column; gap:5px; }
.login-card-row{ display:flex; align-items:center; gap:8px; font-size:.75rem; color:var(--text-muted); }
.login-card-row i{ width:14px; text-align:center; color:var(--brand); opacity:.7; }
.carousel-dots{ display:flex; justify-content:center; gap:6px; margin-top:14px; }
.carousel-dot{ width:7px; height:7px; border-radius:50%; background:var(--border); border:none; padding:0; transition:background .2s, transform .2s; cursor:pointer; }
.carousel-dot.active{ background:var(--brand); transform:scale(1.3); }
.carousel-nav{ display:flex; gap:6px; }
.carousel-btn{ width:30px; height:30px; border-radius:8px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); display:flex; align-items:center; justify-content:center; font-size:.75rem; cursor:pointer; transition:background .15s; }
.carousel-btn:hover{ background:var(--brand); color:#fff; border-color:var(--brand); }

/* Pengumuman */
.ann-card{ border:1px solid var(--border); border-radius:12px; padding:14px 16px; background:var(--surface); margin-bottom:10px; position:relative; }
.ann-card.pinned{ border-color:var(--brand-light,#1d7a6e55); background:rgba(29,122,110,.04); }
.ann-card:last-child{ margin-bottom:0; }
.ann-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; margin-bottom:6px; }
.ann-title{ font-weight:700; font-size:.88rem; }
.ann-content{ font-size:.82rem; color:var(--text-muted); line-height:1.6; }
.ann-meta{ display:flex; align-items:center; gap:10px; margin-top:8px; font-size:.72rem; color:var(--text-muted); }
.ann-actions{ display:flex; gap:5px; flex-shrink:0; }
.pin-icon{ color:var(--brand); font-size:.7rem; }
</style>
<?php $__env->stopSection(); ?>

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


<div class="row g-3 mb-4">
    <div class="col-6 col-lg-3">
        <div class="stat-card">
            <div>
                <div class="label">Total Siswa</div>
                <div class="value"><?php echo e(number_format($totalSiswa)); ?></div>
                <div class="delta text-muted">Terdaftar aktif</div>
            </div>
            <div class="stat-icon" style="background:#e2f1ee;color:#1d7a6e;"><i class="fa-solid fa-user-graduate"></i></div>
        </div>
    </div>
    <div class="col-6 col-lg-3">
        <div class="stat-card">
            <div>
                <div class="label">Total Guru</div>
                <div class="value"><?php echo e($totalGuru); ?></div>
                <div class="delta text-muted"><?php echo e($hadirGuruHariIni > 0 ? $hadirGuruHariIni . ' hadir hari ini' : 'Belum ada absen'); ?></div>
            </div>
            <div class="stat-icon" style="background:#e7f0fb;color:#2d6cd6;"><i class="fa-solid fa-chalkboard-user"></i></div>
        </div>
    </div>
    <div class="col-6 col-lg-3">
        <div class="stat-card">
            <div>
                <div class="label">Jumlah Kelas</div>
                <div class="value"><?php echo e($totalKelas); ?></div>
                <div class="delta text-muted">
                    <?php if(count($kelasBelumAbsen) > 0): ?>
                        <span class="text-warning"><i class="fa-solid fa-triangle-exclamation"></i> <?php echo e(count($kelasBelumAbsen)); ?> belum absen</span>
                    <?php else: ?>
                        Semua sudah absen
                    <?php endif; ?>
                </div>
            </div>
            <div class="stat-icon" style="background:#f3ebfc;color:#7b3fc4;"><i class="fa-solid fa-school"></i></div>
        </div>
    </div>
    <div class="col-6 col-lg-3">
        <div class="stat-card">
            <div>
                <div class="label">Hadir Siswa Hari Ini</div>
                <div class="value"><?php echo e($hadirSiswaHariIni); ?></div>
                <?php if($absenSiswaHariIni > 0): ?>
                    <div class="delta text-warning"><i class="fa-solid fa-triangle-exclamation"></i> <?php echo e($absenSiswaHariIni); ?> tidak hadir</div>
                <?php else: ?>
                    <div class="delta text-muted">dari <?php echo e($totalSiswa); ?> siswa</div>
                <?php endif; ?>
            </div>
            <div class="stat-icon" style="background:#fdf1de;color:#c9821a;"><i class="fa-solid fa-user-check"></i></div>
        </div>
    </div>
</div>


<div class="row g-3 mb-3">
    <div class="col-12 col-xl-8">
        <div class="panel h-100">
            <div class="panel-head">
                <h3><i class="fa-solid fa-bullhorn me-2" style="color:var(--brand);"></i>Pengumuman & Catatan</h3>
            </div>

            <div class="p-3 border-bottom" style="border-color:var(--border)!important;">
                <?php if($errors->any()): ?>
                    <div class="alert alert-danger py-2 mb-2" style="font-size:.8rem;">
                        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div><?php echo e($e); ?></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                <?php endif; ?>
                <form action="<?php echo e(route('admin.announcements.store')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="row g-2 mb-2">
                        <div class="col-12 col-sm-8">
                            <input type="text" name="title" class="form-control" placeholder="Judul pengumuman..." value="<?php echo e(old('title')); ?>" required>
                        </div>
                        <div class="col-12 col-sm-4">
                            <select name="priority" class="form-select" required>
                                <option value="normal" <?php echo e(old('priority') == 'normal' ? 'selected' : ''); ?>>Normal</option>
                                <option value="penting" <?php echo e(old('priority') == 'penting' ? 'selected' : ''); ?>>Penting</option>
                                <option value="mendesak" <?php echo e(old('priority') == 'mendesak' ? 'selected' : ''); ?>>Mendesak</option>
                            </select>
                        </div>
                    </div>
                    <div class="mb-2">
                        <textarea name="content" class="form-control" rows="2" placeholder="Isi catatan atau pengumuman..." required><?php echo e(old('content')); ?></textarea>
                    </div>
                    <button type="submit" class="btn btn-brand">
                        <i class="fa-solid fa-plus me-1"></i> Tambah
                    </button>
                </form>
            </div>

            <div class="p-3" style="max-height:360px;overflow-y:auto;">
                <?php $__empty_1 = true; $__currentLoopData = $announcements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ann): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div class="ann-card <?php echo e($ann->is_pinned ? 'pinned' : ''); ?>">
                        <div class="ann-head">
                            <div>
                                <div class="ann-title">
                                    <?php if($ann->is_pinned): ?><i class="fa-solid fa-thumbtack pin-icon me-1"></i><?php endif; ?>
                                    <?php echo e($ann->title); ?>

                                </div>
                            </div>
                            <div class="d-flex align-items-center gap-2 flex-shrink-0">
                                <span class="role-pill <?php echo e($ann->priorityColor()); ?>">
                                    <i class="fa-solid <?php echo e($ann->priorityIcon()); ?> me-1"></i>
                                    <?php echo e(ucfirst($ann->priority)); ?>

                                </span>
                                <div class="ann-actions">
                                    <form action="<?php echo e(route('admin.announcements.toggle-pin', $ann->id)); ?>" method="POST" class="d-inline">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit" class="icon-btn" title="<?php echo e($ann->is_pinned ? 'Lepas pin' : 'Sematkan'); ?>" style="width:28px;height:28px;">
                                            <i class="fa-solid fa-thumbtack" style="<?php echo e($ann->is_pinned ? 'color:var(--brand);' : ''); ?>"></i>
                                        </button>
                                    </form>
                                    <form action="<?php echo e(route('admin.announcements.destroy', $ann->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Hapus pengumuman ini?')">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn-soft-danger" title="Hapus" style="width:28px;height:28px;">
                                            <i class="fa-solid fa-trash"></i>
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="ann-content"><?php echo e($ann->content); ?></div>
                        <div class="ann-meta">
                            <span><i class="fa-regular fa-user me-1"></i><?php echo e($ann->user->name ?? 'Admin'); ?></span>
                            <span><i class="fa-regular fa-clock me-1"></i><?php echo e($ann->created_at->diffForHumans()); ?></span>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="text-center text-muted py-4">
                        <i class="fa-regular fa-note-sticky" style="font-size:1.5rem;margin-bottom:8px;display:block;"></i>
                        Belum ada pengumuman.
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <div class="col-12 col-xl-4">
        <div class="panel h-100">
            <div class="panel-head"><h3>Akses Cepat</h3></div>
            <div class="p-3">
                <div class="row g-2">
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.students.index')); ?>" class="quick-card">
                            <i class="fa-solid fa-user-plus"></i>
                            <div><div class="qtitle">Data Siswa</div><div class="qsub">Data master</div></div>
                        </a>
                    </div>
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.absen.siswa')); ?>" class="quick-card">
                            <i class="fa-solid fa-clipboard-check"></i>
                            <div><div class="qtitle">Absen Siswa</div><div class="qsub">Rekap hari ini</div></div>
                        </a>
                    </div>
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.absen.guru')); ?>" class="quick-card">
                            <i class="fa-solid fa-user-clock"></i>
                            <div><div class="qtitle">Absen Guru</div><div class="qsub">Input kehadiran</div></div>
                        </a>
                    </div>
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.schedules.index')); ?>" class="quick-card">
                            <i class="fa-solid fa-calendar-plus"></i>
                            <div><div class="qtitle">Jadwal</div><div class="qsub">Akademik</div></div>
                        </a>
                    </div>
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.classes.index')); ?>" class="quick-card">
                            <i class="fa-solid fa-school"></i>
                            <div><div class="qtitle">Data Kelas</div><div class="qsub">Data master</div></div>
                        </a>
                    </div>
                    <div class="col-6">
                        <a href="<?php echo e(route('admin.teachers.index')); ?>" class="quick-card">
                            <i class="fa-solid fa-chalkboard-user"></i>
                            <div><div class="qtitle">Data Guru</div><div class="qsub">Data master</div></div>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="panel">
    <div class="panel-head">
        <h3><i class="fa-solid fa-right-to-bracket me-2" style="color:var(--brand);"></i>Log Login Pengguna</h3>
        <div class="d-flex align-items-center gap-3">
            <span class="text-muted" style="font-size:.75rem;">
                <span class="text-success fw-semibold"><?php echo e($loginHariIni); ?></span> sukses &nbsp;
                <span class="text-danger fw-semibold"><?php echo e($loginGagalHariIni); ?></span> gagal hari ini
            </span>
            <div class="carousel-nav">
                <button class="carousel-btn" id="carouselPrev"><i class="fa-solid fa-chevron-left"></i></button>
                <button class="carousel-btn" id="carouselNext"><i class="fa-solid fa-chevron-right"></i></button>
            </div>
        </div>
    </div>
    <div class="p-3">
        <?php if($loginLogs->isEmpty()): ?>
            <div class="text-center text-muted py-4">Belum ada log login.</div>
        <?php else: ?>
            <div class="login-carousel-wrap">
                <div class="login-carousel" id="loginCarousel">
                    <?php $__currentLoopData = $loginLogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="login-card <?php echo e($log->status); ?>">
                            <div class="login-card-head">
                                <div class="login-card-avatar"><?php echo e(strtoupper(substr($log->user_name, 0, 2))); ?></div>
                                <div>
                                    <div class="login-card-name"><?php echo e($log->user_name); ?></div>
                                    <div class="login-card-email"><?php echo e($log->email); ?></div>
                                </div>
                            </div>
                            <div class="login-card-status">
                                <?php if($log->status === 'success'): ?>
                                    <i class="fa-solid fa-check"></i> Berhasil
                                <?php else: ?>
                                    <i class="fa-solid fa-xmark"></i> Gagal
                                <?php endif; ?>
                            </div>
                            <div class="login-card-meta">
                                <?php if($log->role): ?>
                                    <div class="login-card-row"><i class="fa-solid fa-id-badge"></i><span><?php echo e(ucfirst($log->role)); ?></span></div>
                                <?php endif; ?>
                                <div class="login-card-row"><i class="fa-solid fa-clock"></i><span><?php echo e($log->logged_in_at->format('d/m/Y H:i')); ?></span></div>
                                <div class="login-card-row"><i class="fa-solid fa-network-wired"></i><span><?php echo e($log->ip_address ?? '—'); ?></span></div>
                                <?php if($log->logged_out_at): ?>
                                    <div class="login-card-row"><i class="fa-solid fa-right-from-bracket"></i><span>Logout <?php echo e($log->logged_out_at->format('H:i')); ?></span></div>
                                <?php elseif($log->status === 'success'): ?>
                                    <div class="login-card-row">
                                        <i class="fa-solid fa-circle" style="color:var(--brand);font-size:.5rem;"></i>
                                        <span style="color:var(--brand);font-weight:600;">Sedang Online</span>
                                    </div>
                                <?php endif; ?>
                                <div class="login-card-row"><i class="fa-solid fa-history"></i><span><?php echo e($log->logged_in_at->diffForHumans()); ?></span></div>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <div class="carousel-dots" id="carouselDots"></div>
        <?php endif; ?>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
(function(){
    const carousel = document.getElementById('loginCarousel');
    const dotsWrap = document.getElementById('carouselDots');
    const btnPrev  = document.getElementById('carouselPrev');
    const btnNext  = document.getElementById('carouselNext');
    if (!carousel) return;

    const cardWidth = 260 + 16;
    const visible   = Math.floor(carousel.parentElement.offsetWidth / cardWidth) || 1;
    const cards     = carousel.querySelectorAll('.login-card');
    const maxIndex  = Math.max(0, cards.length - visible);
    let current = 0, autoTimer;

    for (let i = 0; i <= maxIndex; i++) {
        const dot = document.createElement('button');
        dot.className = 'carousel-dot' + (i === 0 ? ' active' : '');
        dot.addEventListener('click', () => goTo(i));
        dotsWrap.appendChild(dot);
    }

    function goTo(i) {
        current = Math.max(0, Math.min(i, maxIndex));
        carousel.style.transform = `translateX(-${current * cardWidth}px)`;
        dotsWrap.querySelectorAll('.carousel-dot').forEach((d, j) => d.classList.toggle('active', j === current));
    }

    function next() { goTo(current >= maxIndex ? 0 : current + 1); }
    function prev() { goTo(current <= 0 ? maxIndex : current - 1); }

    btnNext.addEventListener('click', () => { clearInterval(autoTimer); next(); startAuto(); });
    btnPrev.addEventListener('click', () => { clearInterval(autoTimer); prev(); startAuto(); });

    function startAuto() { autoTimer = setInterval(next, 4000); }
    startAuto();

    carousel.parentElement.addEventListener('mouseenter', () => clearInterval(autoTimer));
    carousel.parentElement.addEventListener('mouseleave', startAuto);
})();
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\sia-sd\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>