<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Sari Rasa | Dashboard</title>

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">

    <style>
        /* Custom Emerald Theme */
        .main-sidebar {
            background-color: #065f46 !important;
        }

        /* Emerald Standar Khusus Tombol */
        .btn-emerald {
            background-color: #10b981 !important;
            color: white !important;
        }

        .brand-link {
            border-bottom: 1px solid #059669 !important;
        }

        /* REVISI UTAMA: Menu Sidebar Aktif Berwarna Kuning Muda & Teks Hitam */
        .nav-pills .nav-link.active,
        .sidebar-dark-primary .nav-sidebar .nav-item .nav-link.active,
        .sidebar-dark-primary .nav-sidebar>.nav-item>.nav-link.active {
            background-color: #fff59d !important; /* Warna Kuning Muda */
            color: #000000 !important; /* Teks Menjadi Hitam */
            font-weight: bold;
        }

        /* REVISI KEDUA: Memaksa Semua Icon (fas) dan Label Menu Aktif Berwarna Hitam Murni */
        .nav-pills .nav-link.active i,
        .nav-pills .nav-link.active p,
        .sidebar-dark-primary .nav-sidebar .nav-item .nav-link.active i,
        .sidebar-dark-primary .nav-sidebar .nav-item .nav-link.active p {
            color: #000000 !important;
        }

        .content-wrapper {
            background-color: #f0fdf4;
        }

        .bg-emerald {
            background-color: #10b981 !important;
            color: white !important;
        }

        .card-emerald.card-outline {
            border-top: 3px solid #10b981 !important;
        }

        .border-emerald {
            border-color: #10b981 !important;
        }

        .text-emerald {
            color: #10b981 !important;
        }

        @media print {
            /* Sembunyikan elemen UI bawaan saat cetak */
            .main-sidebar,
            .main-header,
            .card-tools,
            .info-box,
            .btn,
            .main-footer {
                display: none !important;
            }

            .content-wrapper {
                margin-left: 0 !important;
                background-color: white !important;
                }

            .card {
                border: none !important;
                box-shadow: none !important;
            }

            /* Tampilkan elemen khusus cetak (Kop Surat & Tanda Tangan) */
            .print-only {
                display: block !important;
            }

            /* Hilangkan warna background header tabel agar hemat tinta */
            .table thead th {
                background-color: white !important;
                color: black !important;
                border-color: black !important;
            }

            .table td,
            .table th {
                border-color: black !important;
            }
        }
    </style>
</head>

<body class="hold-transition sidebar-mini">
    <div class="wrapper">

        <nav class="main-header navbar navbar-expand navbar-white navbar-light">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
                </li>
            </ul>
        </nav>

        <aside class="main-sidebar sidebar-dark-primary elevation-4">
            <a href="#" class="brand-link">
                <span class="brand-text font-weight-light pl-3"><b>SARI RASA</b> Pupuk</span>
            </a>
            <div class="user-panel mt-3 pb-3 mb-3 d-flex border-bottom border-emerald">
                <div class="image pt-1">
                    <i class="fas fa-user-circle fa-2x text-light"></i>
                </div>
                <div class="info">
                    <a href="#" class="d-block text-white text-bold"><?= session()->get('nama_lengkap') ?></a>
                    <span class="badge badge-warning text-uppercase"><?= session()->get('role') ?></span>
                </div>
            </div>
            <div class="sidebar">
                <nav class="mt-2">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu">
    
    <li class="nav-item">
        <a href="<?= base_url('dashboard') ?>" class="nav-link <?= url_is('/') || url_is('') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>Beranda</p>
        </a>
    </li>
    
    <li class="nav-header">MANAJEMEN DATA</li>
    
    <li class="nav-item">
        <a href="<?= base_url('petani') ?>" class="nav-link <?= url_is('petani*') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-users"></i>
            <p>Data Petani</p>
        </a>
    </li>
    
    <li class="nav-item <?= url_is('pupuk*') || url_is('transaksi/rekap_penebusan') ? 'menu-open' : '' ?>">
        <a href="#" class="nav-link <?= url_is('pupuk*') || url_is('transaksi/rekap_penebusan') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-boxes"></i>
            <p>Log & Arus Pupuk <i class="right fas fa-angle-left"></i></p>
        </a>
        <ul class="nav nav-treeview pl-3" style="background-color: rgba(255,255,255,0.05);">
            <li class="nav-item">
                <a href="<?= base_url('pupuk') ?>" class="nav-link <?= url_is('pupuk') ? 'active' : '' ?>">
                    <i class="fas fa-layer-group nav-icon text-sm"></i>
                    <p>Stok Gudang Global</p>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('pupukmasuk') ?>" class="nav-link <?= url_is('pupukmasuk*') ? 'active' : '' ?>">
                    <i class="fas fa-download nav-icon text-sm text-success"></i>
                    <p>Pupuk Masuk (Datang)</p>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('transaksi/rekap_penebusan') ?>" class="nav-link <?= url_is('transaksi/rekap_penebusan') ? 'active' : '' ?>">
                    <i class="fas fa-upload nav-icon text-sm text-danger"></i>
                    <p>Rekap Penebusan</p>
                </a>
            </li>
        </ul>
    </li>
    
    <!-- MENU BARU: REKAP MUTASI PUPUK -->
    <li class="nav-item">
        <a href="<?= base_url('transaksi/rekap_pupuk') ?>" 
           class="nav-link <?= url_is('transaksi/rekap_pupuk') ? 'active bg-emerald' : '' ?>">
            <i class="nav-icon fas fa-chart-bar text-warning"></i>
            <p>
                Rekap Mutasi Pupuk
            </p>
        </a>
    </li>
    
    <li class="nav-item">
        <a href="<?= base_url('alokasi') ?>" class="nav-link <?= url_is('alokasi') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-clipboard-list"></i>
            <p>Alokasi e-RDKK</p>
        </a>
    </li>
    
    <li class="nav-header">TRANSAKSI</li>
    
    <li class="nav-item">
        <a href="<?= base_url('transaksi') ?>" class="nav-link <?= url_is('transaksi') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-shopping-cart"></i>
            <p>Penebusan Pupuk</p>
        </a>
    </li>
    
    <li class="nav-header">AKUN & SISTEM</li>
    
    <li class="nav-item">
        <a href="<?= base_url('user') ?>" class="nav-link <?= url_is('user*') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-users-cog"></i>
            <p>Manajemen Pengguna</p>
        </a>
    </li>

    <li class="nav-item">
        <a href="<?= base_url('keuangan') ?>" class="nav-link <?= url_is('keuangan*') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-wallet"></i>
            <p>Laporan Keuangan</p>
        </a>
    </li>

    <li class="nav-item">
        <a href="<?= base_url('alokasi/laporan') ?>" class="nav-link <?= url_is('alokasi/laporan*') ? 'active' : '' ?>">
            <i class="nav-icon fas fa-file-contract"></i>
            <p>Laporan Alokasi (e-RDKK)</p>
        </a>
    </li>
</ul>

                    <li class="nav-header">AKUN</li>
                    <li class="nav-item">
                        <a href="<?= base_url('auth/logout') ?>" class="nav-link text-danger" onclick="return confirm('Yakin ingin keluar dari sistem?')">
                            <i class="nav-icon fas fa-sign-out-alt"></i>
                            <p>Keluar (Logout)</p>
                        </a>
                    </li>
                </nav>
            </div>
        </aside>

        <div class="content-wrapper">
            <section class="content-header">
                <div class="container-fluid">
                    <h1><?= $title ?? 'Sistem Informasi' ?></h1>
                </div>
            </section>

            <section class="content">
                <div class="container-fluid">
                    <?php if (session()->getFlashdata('success')) : ?>
                        <div class="alert alert-success alert-dismissible fade show shadow-sm" role="alert">
                            <i class="icon fas fa-check-circle"></i>
                            <?= session()->getFlashdata('success') ?>
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                    <?php endif; ?>

                    <?php if (session()->getFlashdata('error')) : ?>
                        <div class="alert alert-danger alert-dismissible fade show shadow-sm" role="alert">
                            <i class="icon fas fa-ban"></i>
                            <?= session()->getFlashdata('error') ?>
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                    <?php endif; ?>
                    
                    <?= $this->renderSection('content') ?>
                </div>
            </section>
        </div>

        <footer class="main-footer">
            <div class="float-right d-none d-sm-inline">v1.0</div>
            <strong>Copyright &copy; 2026 Kelompok Tani Sari Rasa.</strong>
        </footer>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/js/adminlte.min.js"></script>
</body>

</html>