<?= $this->extend('layout/template');?>


<?= $this->section('conten');?>

<div class="max-w-7xl mx-auto px-4 py-8">
    <!-- Grid Wrapper Utama -->
    <div class="grid grid-cols-1 lg:grid-cols-4 gap-6 items-start">

        <!-- SEKSI KIRI: KONTEN UTAMA (Lebar 3 Kolom pada desktop) -->
        <div class="lg:col-span-3 space-y-10">

            <!-- A. FORMAT DOKUMEN POPULER -->
            <div>
                <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
                    <div>
                        <h2 class="text-base font-bold text-gray-900 tracking-wide flex items-center gap-2">
                            📁 TEMPLATE DOKUMEN SIAP PAKAI
                        </h2>
                        <p class="text-xs text-gray-400 mt-0.5">Pilih format yang kamu butuhkan — langsung unduh dan gunakan</p>
                    </div>
                    <a href="dokumenfile.html" class="inline-flex items-center text-xs font-semibold text-cyan-600 border border-cyan-500 bg-white px-4 py-1.5 rounded-xl hover:bg-cyan-50 transition shadow-sm self-start sm:self-center">
                        Lihat Semua &rarr;
                    </a>
                </div>

                <!-- Grid Card Template -->
                <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-4">
                    <!-- Card 1: Word -->
                    <a href="<?= base_url('dokumenfile/?type=word')?>" class="block bg-white rounded-2xl p-4 text-center shadow-sm border border-gray-100 hover:shadow-md hover:border-blue-200 transition cursor-pointer">
                        <div class="flex justify-center mb-3">
                            <img src="<?= base_url('asset/image/word.png')?>" class="w-14 h-14 object-contain" alt="Word">
                        </div>
                        <h4 class="text-xs font-bold text-gray-800">Template Word</h4>
                        <p class="text-[10px] text-gray-400 mt-0.5">Format .docx</p>
                        <div class="mt-3">
                            <span class="bg-[#0066cc] text-white text-[9px] font-extrabold px-3 py-1 rounded-md uppercase"><?= $total_word ?> FILE</span>
                        </div>
                    </a>

                    <!-- Card 2: Spreadsheet -->
                    <a href="<?= base_url('dokumenfile/?type=excel')?>" class="block bg-white rounded-2xl p-4 text-center shadow-sm border border-gray-100 hover:shadow-md hover:border-emerald-200 transition cursor-pointer">
                        <div class="flex justify-center mb-3">
                            <img src="<?= base_url('asset/image/xl.png')?>" class="w-14 h-14 object-contain" alt="Excel">
                        </div>
                        <h4 class="text-xs font-bold text-gray-800">Spreadsheet</h4>
                        <p class="text-[10px] text-gray-400 mt-0.5">Format .xlsx</p>
                        <div class="mt-3">
                            <span class="bg-[#00a859] text-white text-[9px] font-extrabold px-3 py-1 rounded-md uppercase"><?= $total_xls ?> FILE</span>
                        </div>
                    </a>

                    <!-- Card 3: Presentasi -->
                    <a href="<?= base_url('dokumenfile/?type=ppt')?>" class="block bg-white rounded-2xl p-4 text-center shadow-sm border border-gray-100 hover:shadow-md hover:border-orange-200 transition cursor-pointer">
                        <div class="flex justify-center mb-3">
                            <img src="<?= base_url('asset/image/ppt.png')?>" class="w-14 h-14 object-contain" alt="PPT">
                        </div>
                        <h4 class="text-xs font-bold text-gray-800">Presentasi</h4>
                        <p class="text-[10px] text-gray-400 mt-0.5">Format .pptx</p>
                        <div class="mt-3">
                            <span class="bg-[#ff5500] text-white text-[9px] font-extrabold px-3 py-1 rounded-md uppercase"><?= $total_ppt ?> FILE</span>
                        </div>
                    </a>

                    <!-- Card 4: Dokumen PDF -->
                    <a href="<?= base_url('dokumenfile/?type=pdf')?>" class="block bg-white rounded-2xl p-4 text-center shadow-sm border border-gray-100 hover:shadow-md hover:border-red-200 transition cursor-pointer">
                        <div class="flex justify-center mb-3">
                            <img src="<?= base_url('asset/image/pdf.png')?>" class="w-14 h-14 object-contain" alt="PDF">
                        </div>
                        <h4 class="text-xs font-bold text-gray-800">Dokumen PDF</h4>
                        <p class="text-[10px] text-gray-400 mt-0.5">Format .pdf</p>
                        <div class="mt-3">
                            <span class="bg-[#e60000] text-white text-[9px] font-extrabold px-3 py-1 rounded-md uppercase"><?= $total_pdf ?> FILE</span>
                        </div>
                    </a>

                    <!-- Card 5: Paket Bundle -->
                    <a href="<?= base_url('dokumenfile/?type=zip')?>" class="block bg-white rounded-2xl p-4 text-center shadow-sm border border-gray-100 hover:shadow-md hover:border-amber-200 transition cursor-pointer">
                        <div class="flex justify-center mb-3">
                            <img src="<?= base_url('asset/image/zip.png')?>" class="w-14 h-14 object-contain" alt="ZIP">
                        </div>
                        <h4 class="text-xs font-bold text-gray-800">Paket Bundle</h4>
                        <p class="text-[10px] text-gray-400 mt-0.5">Format .zip</p>
                        <div class="mt-3">
                            <span class="bg-[#f39c12] text-white text-[9px] font-extrabold px-3 py-1 rounded-md uppercase"><?= $total_zip ?> FILE</span>
                        </div>
                    </a>
                </div>
            </div>

            <!-- B. PANDUAN & TUTORIAL TERBARU -->
            <div>
                <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5">
                    <div>
                        <h2 class="text-base font-bold text-gray-900 tracking-wide flex items-center gap-2">
                            📚 Jelajahi & Pelajari
                        </h2>
                        <p class="text-xs text-gray-400 mt-0.5">Temukan tutorial, referensi, dan berbagai sumber bermanfaat.</p>
                    </div>
                </div>

                <!-- Grid Model Card Dashboard Modern -->
                <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-4">
                    <!-- Card 1 -->
                    <a href="<?= base_url('tutorial')?>" class="group block bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100 hover:shadow-md transition">
                        <div class="h-24 bg-gradient-to-br from-sky-400 to-blue-600 p-4 flex flex-col justify-between relative overflow-hidden">
                            <div class="absolute -right-4 -bottom-4 text-white/10 text-6xl font-bold group-hover:scale-110 transition duration-300">📘</div>
                            <span class="bg-amber-400 text-gray-900 text-[9px] font-bold px-2 py-0.5 rounded-full w-max shadow-sm">📘 Tutorial</span>
                            <h3 class="text-xs font-bold text-white tracking-wide mt-2">Pusat Tutorial</h3>
                        </div>
                        <div class="p-3 bg-white min-h-[4.5rem] flex items-center">
                            <p class="text-[11px] text-gray-500 leading-snug group-hover:text-blue-600 transition">Cari solusi mudah untuk setiap kebutuhanmu.</p>
                        </div>
                    </a>

                    <!-- Card 3 -->
                    <a href="<?= base_url('infografis')?>" class="group block bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100 hover:shadow-md transition">
                        <div class="h-24 bg-gradient-to-br from-amber-500 to-orange-600 p-4 flex flex-col justify-between relative overflow-hidden">
                            <div class="absolute -right-4 -bottom-4 text-white/20 text-6xl font-bold group-hover:scale-110 transition duration-300">🖼️</div>
                            <span class="bg-white text-orange-600 text-[9px] font-bold px-2 py-0.5 rounded-full w-max shadow-sm">🖼️ Gambar</span>
                            <h3 class="text-xs font-bold text-white tracking-wide mt-2">Infografis</h3>
                        </div>
                        <div class="p-3 bg-white min-h-[4.5rem] flex items-center">
                            <p class="text-[11px] text-gray-500 leading-snug group-hover:text-orange-600 transition">Ringkasan informasi materi lewat sajian visual yang menarik.</p>
                        </div>
                    </a>

                    <!-- Card 4 -->
                    <a href="<?= base_url('perpustakaan')?>" class="group block bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100 hover:shadow-md transition">
                        <div class="h-24 bg-gradient-to-br from-purple-600 to-indigo-800 p-4 flex flex-col justify-between relative overflow-hidden">
                            <div class="absolute -right-4 -bottom-4 text-white/10 text-6xl font-bold group-hover:scale-110 transition duration-300">📚</div>
                            <span class="bg-purple-300 text-purple-900 text-[9px] font-bold px-2 py-0.5 rounded-full w-max shadow-sm">📚 Referensi</span>
                            <h3 class="text-xs font-bold text-white tracking-wide mt-2">Perpustakaan Digital</h3>
                        </div>
                        <div class="p-3 bg-white min-h-[4.5rem] flex items-center">
                            <p class="text-[11px] text-gray-500 leading-snug group-hover:text-purple-600 transition">Buku, Skripsi, Modul, Makalah, Semua Dalam Satu Tempat</p>
                        </div>
                    </a>

                    <!-- Card 5 -->
                    <a href="<?= base_url('pojokilmu')?>" class="group block bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100 hover:shadow-md transition">
                        <div class="h-24 bg-gradient-to-br from-pink-600 to-rose-700 p-4 flex flex-col justify-between relative overflow-hidden">
                            <div class="absolute -right-4 -bottom-4 text-white/10 text-6xl font-bold group-hover:scale-110 transition duration-300">💡</div>
                            <span class="bg-rose-300 text-rose-900 text-[9px] font-bold px-2 py-0.5 rounded-full w-max shadow-sm">💡 Edukatif</span>
                            <h3 class="text-xs font-bold text-white tracking-wide mt-2">Pojok Ilmu</h3>
                        </div>
                        <div class="p-3 bg-white min-h-[4.5rem] flex items-center">
                            <p class="text-[11px] text-gray-500 leading-snug group-hover:text-rose-600 transition">Kenali ilmu baru lewat artikel ringan yang mudah dipahami semua kalangan</p>
                        </div>
                    </a>

                    <!-- Card 2 -->
                    <a href="<?= base_url('tools')?>" class="group block bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100 hover:shadow-md transition">
                        <div class="h-24 bg-gradient-to-br from-rose-600 to-red-800 p-4 flex flex-col justify-between relative overflow-hidden">
                            <div class="absolute -right-4 -bottom-4 text-white/10 text-6xl font-bold group-hover:scale-110 transition duration-300">🎬</div>
                            <span class="bg-red-500 text-white text-[9px] font-bold px-2 py-0.5 rounded-full w-max shadow-sm">🛠️ Alat Digital </span>
                            <h3 class="text-xs font-bold text-white tracking-wide mt-2">Alat Digital Gratis</h3>
                        </div>
                        <div class="p-3 bg-white min-h-[4.5rem] flex items-center">
                            <p class="text-[11px] text-gray-500 leading-snug group-hover:text-red-600 transition">Semua proses di browser, tidak ada file yang dikirim ke server. Privat & aman.</p>
                        </div>
                    </a>

                </div>
            </div>



        </div> <!-- AKHIR SEKSI KIRI (Tag penutup dipindah ke sini agar sejajar) -->


        <div class="space-y-3">

            <!-- ===== BOX 1: UPDATE TERKINI ===== -->
            <div class="sb-card">
                <div class="sb-head">
                    <span class="sb-head-icon"><i class="fa-solid fa-folder text-amber-500"></i></span>
                    <h4 class="text-xs font-bold text-slate-800 uppercase tracking-wide ">Dokumen Terbaru</h4>
                </div>

                <!-- ITEM 1: EXCEL -->
                <?php foreach ($dokumen_terbaru as $doc) : ?>
                    <?php 
        // Penentuan icon & warna berdasarkan tipe dokumen (t_dokumen)
                    $tipe = strtolower($doc['t_dokumen']);

                    switch ($tipe) {
                        case 'pdf':
                        $icon  = 'fa-regular fa-file-pdf text-red-600 text-sm w-4 text-center';
                        $color = 'bg-rose-50 text-rose-600';
                        break;
                        case 'excel':
                        $icon  = 'fa-regular fa-file-excel text-emerald-600 text-sm w-4 text-center';
                        $color = 'bg-emerald-50 text-emerald-600';
                        break;
                        case 'word':
                        $icon  = 'fa-regular fa-file-word text-blue-600 text-sm w-4 text-center';
                        $color = 'bg-blue-50 text-blue-600';
                        break;
                        case 'ppt':
                        $icon  = 'fa-regular fa-file-powerpoint text-orange-600 text-sm w-4 text-center';
                        $color = 'bg-orange-50 text-orange-600';
                        break;
                        default:
                        $icon  = 'fa-regular fa-file';
                        $color = 'bg-slate-50 text-slate-600';
                        break;
                    }
                    ?>
                    <a href="<?= base_url('detdoc') ?>?id=<?= $doc['id'] ?>&type=<?= $doc['t_dokumen'] ?>" class="doc-item flex items-center gap-3 p-3 hover:bg-slate-50 transition border-b border-slate-100 last:border-0">
                        <div class="doc-icon-wrap flex items-center justify-center w-9 h-9 rounded-lg bg-emerald-50 shrink-0">
                            <i class="<?= $icon; ?>"></i>
                        </div>
                        <div class="doc-meta flex-1 flex flex-col min-w-0">
                            <span class="doc-meta-name text-xs font-semibold text-slate-700 truncate"><?= esc($doc['n_dokumen']); ?></span>
                            <span class="doc-meta-sub text-[10px] text-slate-400 mt-0.5"><?= ucfirst(esc($doc['t_dokumen'])); ?></span>
                        </div>
                        <span class="doc-arrow text-slate-400 text-sm"><i class="fa-solid fa-chevron-right text-[10px]"></i></span>
                    </a>
                <?php endforeach; ?>
            </div>


           <!-- ===== BOX 4: ARTIKEL PILIHAN ===== -->
        <div class="sb-card">
            <div class="sb-head">
                <span class="sb-head-icon"><i class="fa-solid fa-fire text-blue-600"></i></span>
                <span class="sb-head-label">Tutorial Terbaru</span>
                <span class="sb-badge badge-hot">Populer</span>
            </div>

            <!-- ARTIKEL 1: ADMINISTRASI / SEKOLAH -->
            <?php foreach ($tutorial_terbaru as $doc) : ?>
            <a href="<?= base_url('baca_tutorial/' . $doc['id']); ?>" class="artikel-item flex items-center gap-3 p-3 hover:bg-slate-50 transition border-b border-slate-100 last:border-0">
                <div class="art-thumb flex items-center justify-center w-9 h-9 rounded-lg bg-blue-50 shrink-0">
                    <i class="fa-solid fa-book-open text-blue-600 text-sm"></i>
                </div>
                <div class="flex-1 flex flex-col min-w-0">
                    <span class="art-title text-xs font-semibold text-slate-700 truncate"><?= ucfirst(esc($doc['judul'])); ?><</span>
                    <span class="art-sub text-[10px] text-slate-400 mt-0.5"><i class="fa-regular fa-clock text-[9px] mr-0.5"></i> <?= ucfirst(esc($doc['kategori'])); ?> </span>
                </div>
            </a>
             <?php endforeach; ?>
        </div>



        </div>
        <!-- ===== AKHIR SIDEBAR ===== -->

    </div> <!-- Akhir Grid Utama -->
</div> <!-- Akhir Konten Area Utama -->


<?= $this->endSection(); ?>