<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $title ?? 'Dashboard' ?> - SARPRAS MI MUHAMMADIYAH 27 SURABAYA</title>
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    <!-- FontAwesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <!-- DataTables CSS -->
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.1/css/buttons.dataTables.min.css">
    
    <!-- Custom CSS -->
    <link rel="stylesheet" href="<?= base_url('css/style.css') ?>">
</head>
<body>

    <!-- Sidebar -->
    <aside class="sidebar" id="sidebar">
        <div class="logo">
            <i class="fas fa-school" style="margin-right: 15px;"></i> Sarpras
        </div>
        
        <ul class="nav-list">
            <li class="nav-item">
                <a href="<?= base_url('dashboard') ?>" class="nav-link <?= (url_is('dashboard')) ? 'active' : '' ?>">
                    <i class="fas fa-home"></i> <span>Dashboard</span>
                </a>
            </li>

            <div class="sidebar-title">Data Aset</div>
            <li class="nav-item">
                <a href="<?= base_url('aset/barang') ?>" class="nav-link <?= (url_is('aset/barang')) ? 'active' : '' ?>">
                    <i class="fas fa-boxes"></i> <span>Barang</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('aset/tanah-bangunan') ?>" class="nav-link <?= (url_is('aset/tanah-bangunan')) ? 'active' : '' ?>">
                    <i class="fas fa-building"></i> <span>Tanah & Bangunan</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('aset/buku') ?>" class="nav-link <?= (url_is('aset/buku')) ? 'active' : '' ?>">
                    <i class="fas fa-book"></i> <span>Buku</span>
                </a>
            </li>

            <div class="sidebar-title">Manajemen Data</div>
            <li class="nav-item">
                <a href="<?= base_url('master/ruangan') ?>" class="nav-link <?= (url_is('master/ruangan')) ? 'active' : '' ?>">
                    <i class="fas fa-door-open"></i> <span>Ruangan</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('master/sumber-dana') ?>" class="nav-link <?= (url_is('master/sumber-dana')) ? 'active' : '' ?>">
                    <i class="fas fa-wallet"></i> <span>Sumber Dana</span>
                </a>
            </li>

            <li class="nav-item">
                <a href="<?= base_url('master/kode-barang') ?>" class="nav-link <?= (url_is('master/kode-barang') || url_is('master/kode-barang/*')) ? 'active' : '' ?>">
                    <i class="fas fa-barcode"></i> <span>Kode Barang</span>
                </a>
            </li>

            <div class="sidebar-title">Manajemen Aset</div>
            <li class="nav-item">
                <a href="<?= base_url('transaksi/peminjaman') ?>" class="nav-link <?= (url_is('transaksi/peminjaman')) ? 'active' : '' ?>">
                    <i class="fas fa-handshake"></i> <span>Peminjaman</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('transaksi/perbaikan') ?>" class="nav-link <?= (url_is('transaksi/perbaikan')) ? 'active' : '' ?>">
                    <i class="fas fa-tools"></i> <span>Perbaikan</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('transaksi/pengajuan') ?>" class="nav-link <?= (url_is('transaksi/pengajuan')) ? 'active' : '' ?>">
                    <i class="fas fa-file-signature"></i> <span>Pengajuan</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('transaksi/penghapusan') ?>" class="nav-link <?= (url_is('transaksi/penghapusan')) ? 'active' : '' ?>">
                    <i class="fas fa-trash-alt"></i> <span>Penghapusan</span>
                </a>
            </li>

            <div class="sidebar-title">Laporan</div>
            <li class="nav-item">
                <a href="<?= base_url('laporan/manajemen-aset') ?>" class="nav-link <?= (url_is('laporan/manajemen-aset')) ? 'active' : '' ?>">
                    <i class="fas fa-file-alt"></i> <span>Laporan Manajemen Aset</span>
                </a>
            </li>

            <?php if(session()->get('role') == 'admin'): ?>
            <div class="sidebar-title">Pengaturan</div>
            <li class="nav-item">
                <a href="<?= base_url('users') ?>" class="nav-link <?= (url_is('users')) ? 'active' : '' ?>">
                    <i class="fas fa-users"></i> <span>Manajemen User</span>
                </a>
            </li>
            <?php endif; ?>
        </ul>
    </aside>

    <!-- Main Content -->
    <main class="main-content">
        <!-- Topbar -->
        <header class="topbar">
            <button class="toggle-btn" id="sidebarToggle">
                <i class="fas fa-bars"></i>
            </button>
            
            <div class="user-profile" onclick="document.getElementById('logoutDropdown').classList.toggle('show')">
                <img src="https://ui-avatars.com/api/?name=<?= urlencode(session()->get('name') ?? 'User') ?>&background=4361ee&color=fff" alt="User Profile">
                <div>
                    <strong><?= session()->get('name') ?? 'Guest' ?></strong>
                    <div style="font-size: 12px; color: #666; text-transform: capitalize;"><?= session()->get('role') ?? '' ?></div>
                </div>
                <a href="<?= base_url('auth/logout') ?>" class="btn btn-sm btn-danger" style="margin-left: 15px;"><i class="fas fa-sign-out-alt"></i> Sign Out</a>
            </div>
        </header>

        <!-- Content Area -->
        <section class="content-area">
            <?= $this->renderSection('content') ?>
        </section>
    </main>

    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
    
    <!-- DataTables JS -->
    <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.4.1/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.print.min.js"></script>
    
    <!-- Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <!-- Custom JS -->
    <script src="<?= base_url('js/main.js') ?>"></script>

    <?= $this->renderSection('scripts') ?>
</body>
</html>
