<!DOCTYPE html>
<html lang="id" data-theme="light">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SIS-LAJAR - SMKN 10 Makassar</title>
    <link rel="icon" type="image/png" href="<?php echo e(asset('images/logo-skansa.png')); ?>">
    
    
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    
<style>
    :root {
        --sidebar-width: 260px;
        --navbar-height: 70px;
        --bg-body: #f1f5f9;
        --bg-card: #ffffff;
        --text-main: #1e293b;
        --primary-color: #4361ee;
    }

    body {
        font-family: 'Plus Jakarta Sans', sans-serif;
        background-color: var(--bg-body);
        color: var(--text-main);
        overflow-x: hidden;
        padding-top: var(--navbar-height);
    }

    /* --- TOP NAVBAR --- */
    .top-navbar {
        position: fixed;
        top: 0; left: 0; right: 0;
        height: var(--navbar-height);
        background: #ffffff;
        border-bottom: 1px solid #e2e8f0;
        z-index: 1050; /* Paling Depan */
        display: flex; align-items: center; justify-content: space-between;
        padding: 0 1.5rem;
    }

    .navbar-brand {
        display: flex; align-items: center; gap: 10px;
        font-weight: 700; color: var(--primary-color);
    }

    /* --- SIDEBAR --- */
    .sidebar {
        position: fixed;
        left: 0; 
        top: var(--navbar-height);
        bottom: 0;
        width: var(--sidebar-width);
        background: #ffffff;
        border-right: 1px solid #e2e8f0;
        z-index: 1040; /* Di bawah Navbar, di atas Konten */
        transition: transform 0.3s ease-in-out;
        display: flex; flex-direction: column;
    }

    .sidebar-content {
        flex-grow: 1; overflow-y: auto; padding-bottom: 1rem;
    }

    /* --- MAIN CONTENT (BAGIAN YANG DIPERBAIKI) --- */
    .main-content {
        /* Tambahkan !important agar margin ini TIDAK BISA DIGANGGU */
        margin-left: var(--sidebar-width) !important; 
        
        padding: 2rem;
        min-height: calc(100vh - var(--navbar-height));
        width: calc(100% - var(--sidebar-width)); /* Pastikan lebar pas */
        transition: margin-left 0.3s;
    }

    /* --- RESPONSIVE MOBILE --- */
    @media (max-width: 768px) {
        .sidebar { transform: translateX(-100%); }
        .sidebar.show { transform: translateX(0); }
        
        .main-content { 
            margin-left: 0 !important; /* Reset margin di HP */
            width: 100%;
            padding: 1rem; 
        }
        
        .navbar-widgets, .user-name-text { display: none !important; }
    }

    /* --- STYLE LAINNYA (Tetap Sama) --- */
    .nav-link {
        color: #64748b; font-weight: 500; padding: 0.8rem 1.5rem;
        display: flex; align-items: center; transition: all 0.2s;
    }
    .nav-link:hover, .nav-link.active {
        color: var(--primary-color); background: #f8fafc;
        border-right: 3px solid var(--primary-color);
    }
    .nav-link i { margin-right: 12px; font-size: 1.1rem; }
    .sidebar-heading {
        font-size: 0.7rem; font-weight: 700; color: #94a3b8;
        text-transform: uppercase; padding: 1.5rem 1.5rem 0.5rem;
    }

    /* Widgets */
    .clock-widget {
        display: flex; align-items: center; gap: 10px;
        padding: 5px 15px; background: #f8fafc;
        border: 1px solid #e2e8f0; border-radius: 50px;
    }
    .clock-icon {
        font-size: 1.2rem; color: var(--primary-color);
        background: rgba(67, 97, 238, 0.1); width: 35px; height: 35px;
        display: flex; align-items: center; justify-content: center; border-radius: 50%;
    }
    .clock-time { font-family: 'Courier New', monospace; font-weight: 700; font-size: 1.1rem; line-height: 1; }
    .clock-date { font-size: 0.65rem; color: #64748b; font-weight: 600; text-transform: uppercase; }

    .lesson-widget {
        display: none; align-items: center; gap: 10px;
        padding: 5px 15px 5px 10px; background: #f0fdf4;
        border: 1px solid #bbf7d0; border-radius: 50px;
        animation: fadeIn 0.5s ease-in-out;
    }
    .lesson-icon {
        width: 35px; height: 35px; border-radius: 50%;
        background: #16a34a; color: white;
        display: flex; align-items: center; justify-content: center;
    }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

    .user-dropdown-toggle {
        display: flex; align-items: center; gap: 10px;
        background: transparent; border: none; padding: 5px; border-radius: 50px;
        transition: background 0.2s; cursor: pointer;
    }
    .user-dropdown-toggle:hover { background: #f1f5f9; }
    .user-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #e2e8f0; }
    .user-avatar-placeholder {
        width: 40px; height: 40px; border-radius: 50%; color: white;
        display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 1.1rem;
    }
</style>
</head>
<body>

    
    <nav class="top-navbar">
        <div class="d-flex align-items-center">
            <button class="btn btn-link text-dark p-0 me-3 d-md-none" onclick="document.querySelector('.sidebar').classList.toggle('show')">
                <i class="bi bi-list fs-3"></i>
            </button>
            <div class="navbar-brand">
                
                <img src="<?php echo e(asset('images/logo-skansa.png')); ?>" alt="Logo Skansa" 
                     style="height: 55px; width: auto; object-fit: contain;">
                
                <div class="ms-2">
                    <div style="line-height:1; font-size:1.1rem;">SIS-LAJAR</div>
                    <small style="font-size:0.65rem; color:#64748b; font-weight:500;">SMKN 10 MAKASSAR</small>
                </div>
            </div>
        </div>

        
        <div class="d-flex align-items-center">
            
            
            <div class="clock-widget d-none d-md-flex me-3">
                <div class="clock-icon">
                    <i class="bi bi-clock-history"></i>
                </div>
                <div class="text-start">
                    <div class="clock-time" id="globalClock">
                        <?php echo e(\Carbon\Carbon::now('Asia/Makassar')->format('H:i:s')); ?>

                    </div>
                    <div class="clock-date" id="globalDate">
                        <?php echo e(\Carbon\Carbon::now('Asia/Makassar')->isoFormat('D MMM Y')); ?>

                    </div>
                </div>
            </div>

            
            <div id="navbarLessonWidget" class="lesson-widget">
                <div class="lesson-icon">
                    <i class="bi bi-hourglass-split"></i>
                </div>
                <div class="lh-1 text-start">
                    <div class="fw-bold text-dark" id="currentLessonName" style="font-size: 0.8rem;">-</div>
                    <small class="text-success fw-bold" style="font-size: 0.65rem;">
                        Sisa Waktu: <span id="lessonCountdown">--:--</span>
                    </small>
                </div>
            </div>

            
            <div class="dropdown">
                <div class="user-dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
                    <div class="text-end d-none d-sm-block me-2">
                        <div class="fw-bold text-dark" style="font-size:0.85rem;"><?php echo e(Auth::user()->name); ?></div>
                        <?php
                            $role = Auth::user()->role;
                            $roleColor = match($role) {
                                'super_admin' => 'text-danger',
                                'admin_mapel' => 'text-warning',
                                'guru_mapel' => 'text-success',
                                default => 'text-muted'
                            };
                            $roleBg = match($role) {
                                'super_admin' => '#dc3545',
                                'admin_mapel' => '#ffc107',
                                'guru_mapel' => '#198754',
                                default => '#6c757d'
                            };
                        ?>
                        <div class="<?php echo e($roleColor); ?> fw-bold" style="font-size:0.65rem;">
                            <?php echo e(ucfirst(str_replace('_', ' ', $role))); ?>

                        </div>
                    </div>

                    <?php if(Auth::user()->avatar): ?>
                        <img src="<?php echo e(asset('storage/' . Auth::user()->avatar)); ?>" class="user-avatar" alt="Foto">
                    <?php else: ?>
                        <div class="user-avatar-placeholder" style="background: <?php echo e($roleBg); ?>">
                            <?php echo e(substr(Auth::user()->name, 0, 1)); ?>

                        </div>
                    <?php endif; ?>
                    <i class="bi bi-chevron-down small text-muted ms-1"></i>
                </div>
                <ul class="dropdown-menu dropdown-menu-end shadow border-0 rounded-3 mt-2 p-2" style="width: 220px;">
                    <li><button class="dropdown-item rounded-2 py-2 mb-1" data-bs-toggle="modal" data-bs-target="#modalChangePhoto"><i class="bi bi-camera me-2 text-primary"></i> Ganti Foto Profil</button></li>
                    <li><button class="dropdown-item rounded-2 py-2 mb-1" data-bs-toggle="modal" data-bs-target="#modalChangePassword"><i class="bi bi-key me-2 text-warning"></i> Ganti Password</button></li>
                    <li><hr class="dropdown-divider"></li>
                    <li>
                        <form action="<?php echo e(route('logout')); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <button type="submit" class="dropdown-item rounded-2 py-2 text-danger fw-bold"><i class="bi bi-box-arrow-right me-2"></i> Keluar</button>
                        </form>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    
    <nav class="sidebar">
        <div class="sidebar-content">
            <ul class="nav flex-column pb-3">
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('dashboard') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard')); ?>"><i class="bi bi-grid-fill"></i> Dashboard</a></li>
                <li class="nav-item">
                    <a class="nav-link <?php echo e(request()->is('pesan*') ? 'active' : ''); ?>" href="<?php echo e(route('message.index')); ?>">
                        <div class="d-flex justify-content-between align-items-center w-100">
                            <span><i class="bi bi-chat-left-text-fill"></i> Pesan</span>
                            <?php $unread = \App\Models\Message::where('receiver_id', Auth::id())->where('is_read', 0)->count(); ?>
                            <?php if($unread > 0): ?> <span class="badge bg-danger rounded-pill py-1" style="font-size: 0.65rem;"><?php echo e($unread); ?></span> <?php endif; ?>
                        </div>
                    </a>
                </li>

                <h6 class="sidebar-heading">Perangkat Ajar</h6>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('prota*') ? 'active' : ''); ?>" href="<?php echo e(route('prota.index')); ?>"><i class="bi bi-calendar-check"></i> Prota</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('promes*') ? 'active' : ''); ?>" href="<?php echo e(route('promes.index')); ?>"><i class="bi bi-calendar-week"></i> Promes</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('atp*') ? 'active' : ''); ?>" href="<?php echo e(route('atp.index')); ?>"><i class="bi bi-diagram-3"></i> ATP</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('modul*') ? 'active' : ''); ?>" href="<?php echo e(route('modul.index')); ?>"><i class="bi bi-book"></i> Modul Ajar</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->routeIs('lkpd*') ? 'active' : ''); ?>" href="<?php echo e(route('lkpd.index')); ?>"><i class="bi bi-file-earmark-text"></i> <span>Lembar Kerja (LKPD)</span></a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('asesmen*') ? 'active' : ''); ?>" href="<?php echo e(route('asesmen.index')); ?>"><i class="bi bi-clipboard-check"></i> Asesmen</a></li>

                <h6 class="sidebar-heading">Pembelajaran</h6>
                <li class="nav-item"><a class="nav-link" href="<?php echo e(route('bahanajar.index')); ?>"><i class="bi bi-stars text-warning"></i> Asisten AI</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('pembelajaran/jadwal*') ? 'active' : ''); ?>" href="<?php echo e(route('jadwal.index')); ?>"><i class="bi bi-calendar-event"></i> Jadwal Mengajar</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('pembelajaran/jurnal*') ? 'active' : ''); ?>" href="<?php echo e(route('jurnal.index')); ?>"><i class="bi bi-journal-text"></i> Jurnal Harian</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('penilaian*') ? 'active' : ''); ?>" href="<?php echo e(route('penilaian.index')); ?>"><i class="bi bi-award"></i> Penilaian</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->routeIs('laporan.index') ? 'active' : ''); ?>" href="<?php echo e(route('laporan.index')); ?>"><i class="bi bi-file-earmark-bar-graph"></i> Laporan Pembelajaran</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('laporan/rekap*') ? 'active' : ''); ?>" href="<?php echo e(route('rekap.index')); ?>"><i class="bi bi-table"></i> Rekap Kehadiran</a></li>

                <?php if(Auth::user()->role == 'super_admin'): ?>
                <h6 class="sidebar-heading">Master Data</h6>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('referensi/pengguna*') ? 'active' : ''); ?>" href="<?php echo e(route('pengguna.index')); ?>"><i class="bi bi-people"></i> Pengguna</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('referensi/siswa*') ? 'active' : ''); ?>" href="<?php echo e(route('students.index')); ?>"><i class="bi bi-person-badge"></i> Siswa & Kelas</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('referensi/sekolah*') ? 'active' : ''); ?>" href="<?php echo e(route('sekolah.index')); ?>"><i class="bi bi-building"></i> Sekolah</a></li>
                <li class="nav-item"><a class="nav-link <?php echo e(request()->is('referensi/mapel*') ? 'active' : ''); ?>" href="<?php echo e(route('mapel.index')); ?>"><i class="bi bi-collection"></i> Mapel</a></li>
                <?php endif; ?>
            </ul>
        </div>
    </nav>

    
    <main class="main-content">
        <?php if($errors->any()): ?>
            <div class="alert alert-danger alert-dismissible fade show mb-4">
                <ul class="mb-0">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <li><?php echo e($error); ?></li> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        <?php endif; ?>
        <?php echo $__env->yieldContent('content'); ?>
    </main>

    
    <div class="modal fade" id="modalChangePhoto" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <form action="<?php echo e(route('profile.picture')); ?>" method="POST" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
                    <div class="modal-header"><h5 class="modal-title fw-bold">Ganti Foto Profil</h5><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div>
                    <div class="modal-body text-center">
                        <div class="mb-3">
                            <?php if(Auth::user()->avatar): ?>
<img src="<?php echo e(asset('storage/' . Auth::user()->avatar)); ?>?v=<?php echo e(time()); ?>" class="user-avatar" alt="Foto">                            <?php else: ?>
                                <div class="rounded-circle bg-primary text-white d-flex align-items-center justify-content-center mx-auto shadow-sm" style="width: 100px; height: 100px; font-size: 2.5rem;"><?php echo e(substr(Auth::user()->name, 0, 1)); ?></div>
                            <?php endif; ?>
                        </div>
                        <input type="file" name="avatar" class="form-control" accept="image/*" required>
                    </div>
                    <div class="modal-footer"><button type="submit" class="btn btn-primary rounded-pill px-4">Simpan Foto</button></div>
                </form>
            </div>
        </div>
    </div>

    <div class="modal fade" id="modalChangePassword" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <form action="<?php echo e(route('profile.password')); ?>" method="POST">
                    <?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
                    <div class="modal-header"><h5 class="modal-title fw-bold">Ganti Password</h5><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div>
                    <div class="modal-body">
                        <div class="mb-3"><label class="form-label">Password Lama</label><input type="password" name="current_password" class="form-control" required></div>
                        <div class="mb-3"><label class="form-label">Password Baru</label><input type="password" name="password" class="form-control" required minlength="6"></div>
                        <div class="mb-3"><label class="form-label">Konfirmasi Password Baru</label><input type="password" name="password_confirmation" class="form-control" required></div>
                    </div>
                    <div class="modal-footer"><button type="submit" class="btn btn-warning text-white rounded-pill px-4">Update Password</button></div>
                </form>
            </div>
        </div>
    </div>
<div id="fullscreenNotification" style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(67, 97, 238, 0.95); z-index: 9999; align-items: center; justify-content: center; flex-direction: column; color: white; transition: opacity 0.5s ease;">
        <i class="bi bi-bell-fill mb-3" style="font-size: 5rem; animation: swing 1s ease-in-out infinite alternate;"></i>
        <h1 class="fw-bold display-4 text-center px-3" id="notifMessage">Waktunya Jam Ke-1</h1>
        <p class="fs-4 text-white-50 mt-2">Mohon bersiap untuk pergantian sesi.</p>
    </div>

    <style>
        @keyframes swing {
            0% { transform: rotate(15deg); }
            100% { transform: rotate(-15deg); }
        }
    </style>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // --- 1. JAM GLOBAL ---
        function updateGlobalClock() {
            const now = new Date();
            const timeStr = now.toLocaleTimeString('id-ID', { hour12: false, timeZone: 'Asia/Makassar' });
            const dateStr = now.toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' });
            
            const elClock = document.getElementById('globalClock');
            const elDate = document.getElementById('globalDate');
            if(elClock) elClock.innerText = timeStr;
            if(elDate) elDate.innerText = dateStr;
        }
        setInterval(updateGlobalClock, 1000);

        // --- 2. WIDGET STATUS PELAJARAN (NAVBAR) & NOTIFIKASI PERGANTIAN ---
        const schedules = <?php echo json_encode($globalLessonHours ?? [], 15, 512) ?>; 
        let previousLessonName = null; // Menyimpan nama pelajaran sebelumnya

        function showFullscreenNotification(message) {
            const notifEl = document.getElementById('fullscreenNotification');
            const msgEl = document.getElementById('notifMessage');
            
            msgEl.innerText = "Sekarang " + message;
            notifEl.style.display = 'flex';
            notifEl.style.opacity = '0'; // Mulai dari transparan
            
            // Fade In
            setTimeout(() => { notifEl.style.opacity = '1'; }, 50);

            // Menghilang setelah 2 detik
            setTimeout(() => {
                notifEl.style.opacity = '0'; // Fade Out
                setTimeout(() => { notifEl.style.display = 'none'; }, 500); // Sembunyikan div setelah transisi selesai
            }, 2500);
        }

        function updateLessonStatus() {
            if (!schedules || schedules.length === 0) return;
            const now = new Date();
            const currentTime = now.getHours() * 60 + now.getMinutes();
            
            let activeLesson = null, nextLesson = null;
            let container = document.getElementById('navbarLessonWidget');

            for (let i = 0; i < schedules.length; i++) {
                let s = parseTime(schedules[i].start_time);
                let e = parseTime(schedules[i].end_time);
                
                if (currentTime >= s && currentTime < e) { activeLesson = schedules[i]; break; }
                if (s > currentTime && !nextLesson) { nextLesson = schedules[i]; }
            }

            // --- LOGIKA MENDETEKSI PERGANTIAN JAM ---
            if (activeLesson) {
                // Jika lesson name berubah dan sebelumnya bukan null, berarti terjadi pergantian
                if (previousLessonName !== null && previousLessonName !== activeLesson.name) {
                    showFullscreenNotification(activeLesson.name);
                }
                // Simpan nama pelajaran saat ini untuk dicek di detik berikutnya
                previousLessonName = activeLesson.name;

                container.style.display = 'flex'; 
                document.getElementById('currentLessonName').innerText = activeLesson.name;
                
                let t = new Date(); let [h,m] = activeLesson.end_time.split(':'); t.setHours(h,m,0);
                document.getElementById('lessonCountdown').innerText = fmt(t - now);
            } else if (nextLesson) {
                // Jika sedang tidak ada pelajaran aktif, reset ke null
                previousLessonName = null; 

                container.style.display = 'flex';
                document.getElementById('currentLessonName').innerText = "Menuju: " + nextLesson.name;
                
                let t = new Date(); let [h,m] = nextLesson.start_time.split(':'); t.setHours(h,m,0);
                document.getElementById('lessonCountdown').innerText = fmt(t - now);
            } else {
                previousLessonName = null;
                container.style.display = 'none';
            }
        }

        function parseTime(t) { if(!t) return 0; let p=t.split(':'); return parseInt(p[0])*60 + parseInt(p[1]); }
        function fmt(ms) { if(ms<0) return "00:00"; let s=Math.floor(ms/1000); let m=Math.floor(s/60); return (m<10?"0"+m:m) + ":" + (s%60<10?"0"+(s%60):(s%60)); }
        
        setInterval(updateLessonStatus, 1000); setTimeout(updateLessonStatus, 500);
    </script>
    <?php echo $__env->yieldContent('scripts'); ?>
</body>
</html><?php /**PATH /home/vol15_7/infinityfree.com/if0_40829333/htdocs/resources/views/layouts/app.blade.php ENDPATH**/ ?>