<!DOCTYPE html>
<html lang="id">
<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')); ?>">
    
    
    <script>
        const savedTheme = localStorage.getItem('sis-lajar-theme') || 'light';
        document.documentElement.setAttribute('data-bs-theme', savedTheme);
    </script>
    
    
    <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;800&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>
    /* =========================================================
       1. VARIABEL TEMA TERANG (LIGHT MODE)
       ========================================================= */
    :root {
        --sidebar-width: 285px;
        --navbar-height: 75px; 
        
        --bg-body: #f8fafc; 
        --bg-card: #ffffff;
        --text-main: #1e293b;
        --text-muted: #64748b;
        --border-color: #e2e8f0;
        
        /* Tema Biru Muda - Biru Tua */
        --primary-color: #3b82f6; 
        --primary-hover: #1e40af; 
        --navbar-bg: rgba(255, 255, 255, 0.85);
        --hover-bg: #f1f5f9;
        
        /* Komponen Input & Tabel */
        --input-bg: #ffffff;
        --table-header-bg: #f8fafc;
        --badge-soft-bg: rgba(59, 130, 246, 0.1);
        --icon-filter: none;
    }

    /* =========================================================
       2. VARIABEL TEMA GELAP (DARK MODE)
       ========================================================= */
    [data-bs-theme="dark"] {
        --bg-body: #0f172a; 
        --bg-card: #1e293b; 
        --text-main: #f8fafc;
        --text-muted: #94a3b8;
        --border-color: #334155;
        
        --primary-color: #60a5fa; 
        --primary-hover: #3b82f6; 
        --navbar-bg: rgba(30, 41, 59, 0.85);
        --hover-bg: rgba(255, 255, 255, 0.05);

        --input-bg: rgba(255, 255, 255, 0.05);
        --table-header-bg: rgba(255, 255, 255, 0.03);
        --badge-soft-bg: rgba(59, 130, 246, 0.2);
        --icon-filter: invert(1) grayscale(100%) brightness(200%);
    }

    /* =========================================================
       3. PENERAPAN OTOMATIS KE KOMPONEN GLOBAL
       ========================================================= */
    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);
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    .card, .modern-card, .modal-content, .accordion-item {
        background-color: var(--bg-card) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-main);
        transition: all 0.3s ease;
    }
    .card-header, .modal-header, .modal-footer, .border-bottom, .border-top { border-color: var(--border-color) !important; }
    h1, h2, h3, h4, h5, h6, strong, label, .form-label, .modal-title, .accordion-button { color: var(--text-main) !important; }
    .text-muted, .small.text-muted { color: var(--text-muted) !important; }

    /* Form, Input & Tabel */
    .form-control, .form-select, textarea {
        background-color: var(--input-bg) !important; border: 1px solid var(--border-color) !important;
        color: var(--text-main) !important; border-radius: 12px;
    }
    .form-control:focus, .form-select:focus {
        border-color: var(--primary-color) !important; box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25) !important;
        background-color: var(--bg-card) !important;
    }
    .table { color: var(--text-main); border-color: var(--border-color); }
    .table-light th, .table-secondary th, thead th { background-color: var(--table-header-bg) !important; color: var(--text-main) !important; border-color: var(--border-color) !important; }
    .table-hover tbody tr:hover td { background-color: var(--hover-bg) !important; color: var(--text-main); }
    .btn-close { filter: var(--icon-filter); }

    /* --- TOP NAVBAR --- */
    .top-navbar {
        position: fixed; top: 0; left: 0; right: 0; height: var(--navbar-height);
        background: var(--navbar-bg); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color);
        z-index: 1050; display: flex; align-items: center; justify-content: space-between; padding: 0 2rem;
    }
    .navbar-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--primary-color); }
    [data-bs-theme="dark"] .navbar-brand img { filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.3)); }

    /* --- SIDEBAR --- */
    .sidebar {
        position: fixed; left: 0; top: var(--navbar-height); bottom: 0; width: var(--sidebar-width);
        background: var(--bg-card); border-right: 1px solid var(--border-color); z-index: 1040;
        transition: transform 0.3s ease-in-out; display: flex; flex-direction: column;
    }
    .sidebar-content { flex-grow: 1; overflow-y: auto; padding-bottom: 2rem; }
    .sidebar-content::-webkit-scrollbar { width: 5px; }
    .sidebar-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

    .nav-link {
        color: var(--text-muted); font-weight: 600; padding: 0.55rem 1.2rem; display: flex; align-items: center; 
        transition: all 0.3s ease; border-radius: 50rem; margin: 0.15rem 1.2rem;
    }
    .nav-link:hover { color: var(--text-main); background: var(--hover-bg); transform: translateX(5px); }
    .nav-link.active {
        color: #ffffff !important; background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
        box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    }
    .nav-link.active i { color: #ffffff !important; }
    .nav-link i { margin-right: 12px; font-size: 1.1rem; }
    
    .sidebar-heading {
        font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; 
        letter-spacing: 1px; padding: 1.2rem 1.5rem 0.5rem;
    }

    .main-content {
        margin-left: var(--sidebar-width) !important; padding: 2.5rem; min-height: calc(100vh - var(--navbar-height));
        width: calc(100% - var(--sidebar-width)); transition: margin-left 0.3s;
    }

    @media (max-width: 768px) {
        .sidebar { transform: translateX(-100%); } .sidebar.show { transform: translateX(0); }
        .main-content { margin-left: 0 !important; width: 100%; padding: 1.5rem; } .top-navbar { padding: 0 1rem; }
    }

    .theme-toggle-btn {
        background: var(--hover-bg); border: 1px solid var(--border-color); border-radius: 50%; width: 40px; height: 40px; 
        display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; color: var(--text-main);
    }
    .theme-toggle-btn:hover { transform: rotate(15deg) scale(1.1); border-color: var(--primary-color); }

    /* Widgets Navbar */
    .clock-widget, .lesson-widget {
        display: flex; align-items: center; gap: 12px; padding: 6px 20px 6px 8px; 
        background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 50rem;
        cursor: pointer; transition: transform 0.2s; 
    }
    .clock-widget:hover, .lesson-widget:hover { transform: translateY(-2px); border-color: var(--primary-color); }
    .clock-icon, .lesson-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
    .clock-icon { background: var(--badge-soft-bg); color: var(--primary-color); }
    .lesson-icon { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
    .clock-time { font-family: monospace; font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
    .clock-date { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }

    /* Calendar CSS */
    .calendar-header { display: flex; justify-content: space-between; align-items: center; font-weight: bold; margin-bottom: 10px; }
    .calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.8rem; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
    .calendar-dates { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px; }
    .calendar-date { padding: 6px 0; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.2s; }
    .calendar-date:hover:not(.empty) { background: var(--hover-bg); color: var(--primary-color); font-weight: bold; }
    .calendar-date.today { background: var(--primary-color); color: white !important; font-weight: bold; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4); }
    .calendar-date.empty { cursor: default; }

    .user-dropdown-toggle { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border-color); padding: 6px 12px 6px 16px; border-radius: 50rem; cursor: pointer; }
    .user-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color); }
</style>
</head>
<body>

    
    <nav class="top-navbar">
        <div class="d-flex align-items-center">
            <button class="btn btn-outline-secondary rounded-circle p-2 me-3 d-md-none border-0" style="width: 45px; height: 45px;" onclick="document.querySelector('.sidebar').classList.toggle('show')">
                <i class="bi bi-list fs-4"></i>
            </button>
            <div class="navbar-brand">
                <img src="<?php echo e(asset('images/logo-skansa.png')); ?>" alt="Logo Skansa" style="height: 48px; width: auto; object-fit: contain;">
                <div class="ms-1">
                    <div style="line-height:1; font-size:1.2rem; font-weight: 800; letter-spacing: -0.5px;">SIS-LAJAR</div>
                    <small style="font-size:0.7rem; font-weight:600; letter-spacing: 0.5px;" class="text-muted">SMKN 10 MAKASSAR</small>
                </div>
            </div>
        </div>

        <div class="d-flex align-items-center gap-3">
            
            
            <button class="theme-toggle-btn shadow-sm" id="themeToggle" title="Ganti Tema">
                <i class="bi bi-moon-stars-fill fs-5" id="themeIcon"></i>
            </button>

            
            <div class="dropdown">
                <div class="clock-widget shadow-sm" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside" title="Lihat Kalender">
                    <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 text-muted" id="globalDate"><?php echo e(\Carbon\Carbon::now('Asia/Makassar')->isoFormat('dddd, D MMM Y')); ?></div>
                    </div>
                </div>
                
                <div class="dropdown-menu dropdown-menu-end shadow-lg border-0 rounded-4 p-3 mt-2" style="width: 320px; background-color: var(--bg-card);">
                    <div class="calendar-header px-1">
                        <button class="btn btn-sm btn-light rounded-circle" id="prevMonth"><i class="bi bi-chevron-left"></i></button>
                        <span id="calendarMonthYear" class="fw-bold fs-6">Bulan Tahun</span>
                        <button class="btn btn-sm btn-light rounded-circle" id="nextMonth"><i class="bi bi-chevron-right"></i></button>
                    </div>
                    <div class="calendar-days mt-2">
                        <div>Min</div><div>Sen</div><div>Sel</div><div>Rab</div><div>Kam</div><div>Jum</div><div>Sab</div>
                    </div>
                    <div class="calendar-dates" id="calendarDates"></div>
                </div>
            </div>

            
            <div id="navbarLessonWidget" class="lesson-widget shadow-sm" style="display: flex;" data-bs-toggle="modal" data-bs-target="#modalLessonSchedule" title="Lihat Detail Jam Pelajaran">
                <div class="lesson-icon"><i class="bi bi-hourglass-split"></i></div>
                <div class="lh-1 text-start">
                    <div class="fw-bold" style="font-size: 0.85rem;" id="currentLessonName">-</div>
                    <small class="text-success fw-bold" style="font-size: 0.7rem;">Sisa: <span id="lessonCountdown">--:--</span></small>
                </div>
            </div>

            <div class="dropdown">
                <div class="user-dropdown-toggle shadow-sm" data-bs-toggle="dropdown" aria-expanded="false">
                    <div class="text-end d-none d-sm-block">
                        <div class="fw-bold" style="font-size:0.9rem;"><?php echo e(Auth::user()->name ?? 'Guru'); ?></div>
                        <div class="text-muted fw-bold" style="font-size:0.7rem;"><?php echo e(ucfirst(str_replace('_', ' ', Auth::user()->role ?? 'Admin'))); ?></div>
                    </div>
                    <?php if(Auth::user() && Auth::user()->avatar): ?>
                        <img src="<?php echo e(asset('storage/' . Auth::user()->avatar)); ?>" class="user-avatar" alt="Foto">
                    <?php else: ?>
                        <div class="user-avatar bg-primary text-white d-flex align-items-center justify-content-center fw-bold fs-6 border-0">
                            <?php echo e(substr(Auth::user()->name ?? 'G', 0, 1)); ?>

                        </div>
                    <?php endif; ?>
                </div>
                <ul class="dropdown-menu dropdown-menu-end shadow-lg border-0 rounded-4 mt-3 p-2" style="background-color: var(--bg-card); width: 240px;">
                    <li><button class="dropdown-item rounded-pill py-2 mb-1 fw-medium" 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-pill py-2 mb-1 fw-medium" 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" style="border-color: var(--border-color);"></li>
                    <li>
                        <form action="<?php echo e(route('logout')); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <button type="submit" class="dropdown-item rounded-pill 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 shadow-sm">
        <div class="sidebar-content">
            <ul class="nav flex-column pb-3 mt-4">
                <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 px-2" style="font-size: 0.7rem;"><?php echo e($unread); ?></span> <?php endif; ?>
                        </div>
                    </a>
                </li>

                <h6 class="sidebar-heading mt-2">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 mt-2">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 Belajar</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() && Auth::user()->role == 'super_admin'): ?>
                <h6 class="sidebar-heading mt-2">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 rounded-4 border-0 shadow-sm border-start border-danger border-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 shadow-lg border-0 rounded-4">
                <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-4 mt-2">
                            <?php if(Auth::user() && Auth::user()->avatar): ?>
                                <img src="<?php echo e(asset('storage/' . Auth::user()->avatar)); ?>?v=<?php echo e(time()); ?>" class="user-avatar" style="width: 120px; height: 120px;" 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: 120px; height: 120px; font-size: 3rem;"><?php echo e(substr(Auth::user()->name ?? 'G', 0, 1)); ?></div>
                            <?php endif; ?>
                        </div>
                        <input type="file" name="avatar" class="form-control rounded-pill" accept="image/*" required>
                    </div>
                    <div class="modal-footer"><button type="submit" class="btn btn-primary rounded-pill px-5 fw-bold w-100">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 shadow-lg border-0 rounded-4">
                <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 p-4">
                        <div class="mb-3">
                            <label class="form-label small fw-bold text-muted text-uppercase">Password Lama</label>
                            <input type="password" name="current_password" class="form-control rounded-pill py-2" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label small fw-bold text-muted text-uppercase">Password Baru</label>
                            <input type="password" name="password" class="form-control rounded-pill py-2" required minlength="6">
                        </div>
                        <div class="mb-2">
                            <label class="form-label small fw-bold text-muted text-uppercase">Konfirmasi Password Baru</label>
                            <input type="password" name="password_confirmation" class="form-control rounded-pill py-2" required>
                        </div>
                    </div>
                    <div class="modal-footer"><button type="submit" class="btn btn-warning text-dark rounded-pill px-5 fw-bold w-100">Update Password</button></div>
                </form>
            </div>
        </div>
    </div>

    <div class="modal fade" id="modalLessonSchedule" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content shadow-lg border-0 rounded-4">
                <div class="modal-header border-bottom px-4 py-3">
                    <h5 class="modal-title fw-bold">
                        <div class="lesson-icon d-inline-flex me-2 shadow-sm" style="width: 30px; height: 30px; font-size: 0.9rem;"><i class="bi bi-hourglass-split"></i></div>
                        Detail Jam Pembelajaran
                    </h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover mb-0 text-center align-middle">
                            <thead class="table-light">
                                <tr>
                                    <th class="py-3">Jam Ke</th>
                                    <th class="py-3">Waktu Pelaksanaan</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $globalLessonHours ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lesson): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="fw-bold py-3 text-primary"><?php echo e($lesson->name ?? 'Jam ' . $loop->iteration); ?></td>
                                    <td class="py-3 fw-medium">
                                        <i class="bi bi-clock me-1 text-muted"></i> 
                                        <?php echo e(\Carbon\Carbon::parse($lesson->start_time)->format('H:i')); ?> - <?php echo e(\Carbon\Carbon::parse($lesson->end_time)->format('H:i')); ?> WITA
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="2" class="text-muted py-5">
                                        <i class="bi bi-calendar-x fs-1 d-block mb-2"></i>
                                        Data referensi jam pelajaran sekolah belum tersedia.
                                    </td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer bg-light border-0 rounded-bottom-4">
                    <button type="button" class="btn btn-secondary rounded-pill px-4" data-bs-dismiss="modal">Tutup</button>
                </div>
            </div>
        </div>
    </div>

    
    <div id="fullscreenNotification" style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(59, 130, 246, 0.95); z-index: 9999; align-items: center; justify-content: center; flex-direction: column; color: white; transition: opacity 0.5s ease; backdrop-filter: blur(10px);">
        <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>
        // --- LOGIKA THEME TOGGLE (DARK/LIGHT) ---
        const themeToggleBtn = document.getElementById('themeToggle');
        const themeIcon = document.getElementById('themeIcon');
        const htmlEl = document.documentElement;

        function updateThemeIcon(theme) {
            if(theme === 'dark') {
                themeIcon.classList.remove('bi-moon-stars-fill'); themeIcon.classList.add('bi-sun-fill'); themeIcon.style.color = '#f59e0b'; 
            } else {
                themeIcon.classList.remove('bi-sun-fill'); themeIcon.classList.add('bi-moon-stars-fill'); themeIcon.style.color = 'var(--text-main)'; 
            }
        }
        updateThemeIcon(htmlEl.getAttribute('data-bs-theme'));

        themeToggleBtn.addEventListener('click', () => {
            const newTheme = htmlEl.getAttribute('data-bs-theme') === 'dark' ? 'light' : 'dark';
            htmlEl.setAttribute('data-bs-theme', newTheme);
            localStorage.setItem('sis-lajar-theme', newTheme);
            updateThemeIcon(newTheme);
        });

        // --- 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', { weekday: 'long', 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);

        // --- KALENDER DROPDOWN ---
        let currentCalDate = new Date(); // Date state untuk kalender
        
        function renderCalendar() {
            const year = currentCalDate.getFullYear();
            const month = currentCalDate.getMonth();
            const today = new Date();

            const monthNames = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"];
            document.getElementById('calendarMonthYear').innerText = `${monthNames[month]} ${year}`;

            const firstDay = new Date(year, month, 1).getDay(); // 0 is Sunday
            const daysInMonth = new Date(year, month + 1, 0).getDate();
            const datesContainer = document.getElementById('calendarDates');
            
            datesContainer.innerHTML = '';

            // Blank spaces untuk hari sebelum awal bulan
            for (let i = 0; i < firstDay; i++) {
                datesContainer.innerHTML += `<div class="calendar-date empty"></div>`;
            }

            // Print tanggal bulan ini
            for (let i = 1; i <= daysInMonth; i++) {
                const isToday = (i === today.getDate() && month === today.getMonth() && year === today.getFullYear());
                const todayClass = isToday ? 'today' : '';
                datesContainer.innerHTML += `<div class="calendar-date ${todayClass}">${i}</div>`;
            }
        }

        document.getElementById('prevMonth').addEventListener('click', (e) => {
            e.stopPropagation(); // Mencegah dropdown tertutup
            currentCalDate.setMonth(currentCalDate.getMonth() - 1);
            renderCalendar();
        });

        document.getElementById('nextMonth').addEventListener('click', (e) => {
            e.stopPropagation(); // Mencegah dropdown tertutup
            currentCalDate.setMonth(currentCalDate.getMonth() + 1);
            renderCalendar();
        });
        
        // Panggil render saat pertama load
        renderCalendar();

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

        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'; 
            
            setTimeout(() => { notifEl.style.opacity = '1'; }, 50);
            setTimeout(() => {
                notifEl.style.opacity = '0'; 
                setTimeout(() => { notifEl.style.display = 'none'; }, 500); 
            }, 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]; }
            }

            if (activeLesson) {
                if (previousLessonName !== null && previousLessonName !== activeLesson.name) {
                    showFullscreenNotification(activeLesson.name);
                }
                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) {
                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;
                // Widget tetap ditampilkan agar modal jadwal bisa dibuka
                container.style.display = 'flex';
                document.getElementById('currentLessonName').innerText = "Jadwal Pelajaran";
                document.getElementById('lessonCountdown').innerText = "Selesai";
            }
        }

        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/sislajar-skansa.gt.tc/htdocs/resources/views/layouts/app.blade.php ENDPATH**/ ?>