<?php
session_start();
require_once '../config/database.php';
require_once '../config/function.php';

// Cek login
checkLogin();

$current_user = getCurrentUser();
$tahun_ajaran = getTahunAjaranAktif();

// Query untuk statistik
$tahun_ajaran_id = $tahun_ajaran ? $tahun_ajaran['id_tahun_ajaran'] : 0;

// Total siswa aktif
$query_siswa = "SELECT COUNT(*) as total FROM bkcare_siswa WHERE status = 'aktif'";
$result_siswa = mysqli_query($conn, $query_siswa);
$total_siswa = mysqli_fetch_assoc($result_siswa)['total'];

// Total konseling aktif
$query_konseling = "SELECT COUNT(*) as total FROM bkcare_konseling 
                    WHERE status = 'proses' AND id_tahun_ajaran = '$tahun_ajaran_id'";
$result_konseling = mysqli_query($conn, $query_konseling);
$total_konseling = mysqli_fetch_assoc($result_konseling)['total'];

// Total laporan baru
$query_laporan = "SELECT COUNT(*) as total FROM bkcare_laporan_masalah 
                  WHERE status = 'baru' AND id_tahun_ajaran = '$tahun_ajaran_id'";
$result_laporan = mysqli_query($conn, $query_laporan);
$total_laporan = mysqli_fetch_assoc($result_laporan)['total'];

// Total pelanggaran bulan ini
$bulan_ini = date('Y-m');
$query_pelanggaran = "SELECT COUNT(*) as total FROM bkcare_pelanggaran 
                      WHERE DATE_FORMAT(tanggal, '%Y-%m') = '$bulan_ini' 
                      AND id_tahun_ajaran = '$tahun_ajaran_id'";
$result_pelanggaran = mysqli_query($conn, $query_pelanggaran);
$total_pelanggaran = mysqli_fetch_assoc($result_pelanggaran)['total'];

$query_recent_laporan = "SELECT l.*, s.nama as nama_siswa, u.nama as nama_pelapor,
                        DATE_FORMAT(l.tanggal, '%d %M %Y') as tgl_format
                        FROM bkcare_laporan_masalah l
                        JOIN bkcare_siswa s ON l.id_siswa = s.id_siswa
                        LEFT JOIN bkcare_users u ON l.id_pelapor = u.id_user
                        WHERE l.id_tahun_ajaran = '$tahun_ajaran_id'
                        ORDER BY l.tanggal DESC
                        LIMIT 5";
$recent_laporan = mysqli_query($conn, $query_recent_laporan);

if (!$recent_laporan) {
    die("Error query: " . mysqli_error($conn));
}

// Jadwal konseling hari ini
$hari_ini = date('Y-m-d');
$query_jadwal = "SELECT j.*, s.nama as nama_siswa, g.nama_guru,
                DATE_FORMAT(j.tanggal, '%d %M %Y') as tgl_format,
                TIME_FORMAT(j.jam, '%H:%i') as jam_format
                FROM bkcare_jadwal_konseling j
                JOIN bkcare_siswa s ON j.id_siswa = s.id_siswa
                LEFT JOIN bkcare_guru g ON j.id_guru_bk = g.id_guru
                WHERE j.tanggal = '$hari_ini' AND j.id_tahun_ajaran = '$tahun_ajaran_id'
                ORDER BY j.jam ASC
                LIMIT 5";
$jadwal_hari_ini = mysqli_query($conn, $query_jadwal);

// Query grafik perkembangan konseling per bulan (BATANG)
$query_grafik = "SELECT 
                    DATE_FORMAT(tanggal, '%b') as bulan_singkat,
                    DATE_FORMAT(tanggal, '%M') as bulan,
                    DATE_FORMAT(tanggal, '%m') as bulan_num,
                    COUNT(*) as total
                FROM bkcare_konseling
                WHERE id_tahun_ajaran = '$tahun_ajaran_id'
                    AND tanggal >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
                GROUP BY DATE_FORMAT(tanggal, '%b'), DATE_FORMAT(tanggal, '%M'), DATE_FORMAT(tanggal, '%m')
                ORDER BY MIN(tanggal) ASC";

$data_grafik = mysqli_query($conn, $query_grafik);

$bulan_labels = [];
$total_konseling_data = [];

while ($row = mysqli_fetch_assoc($data_grafik)) {
    $bulan_labels[] = $row['bulan_singkat'];
    $total_konseling_data[] = $row['total'];
}

// Jika tidak ada data, tampilkan data dummy
if (empty($bulan_labels)) {
    $bulan_labels = ['Okt', 'Nov', 'Des', 'Jan', 'Feb', 'Mar'];
    $total_konseling_data = [2, 3, 4, 5, 6, 7];
}

// Prestasi siswa
$query_prestasi = "SELECT p.*, s.nama as nama_siswa,
                  DATE_FORMAT(p.tanggal, '%d %M %Y') as tgl_format
                  FROM bkcare_perkembangan_siswa p
                  JOIN bkcare_siswa s ON p.id_siswa = s.id_siswa
                  WHERE p.kategori = 'akademik' 
                  AND (p.catatan LIKE '%prestasi%' OR p.catatan LIKE '%baik%' OR p.catatan LIKE '%meningkat%')
                  AND p.id_tahun_ajaran = '$tahun_ajaran_id'
                  ORDER BY p.tanggal DESC
                  LIMIT 5";
$prestasi = mysqli_query($conn, $query_prestasi);

include '../includes/header.php';
include '../includes/navbar.php';
?>

<!-- Custom CSS untuk Dashboard -->
<style>
    .stat-card {
        transition: all 0.3s ease;
        border: 1px solid rgba(102, 126, 234, 0.1);
    }
    .stat-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        border-color: rgba(102, 126, 234, 0.3);
    }
    .chart-container {
        position: relative;
        height: 280px;
        width: 100%;
    }
    .badge-custom {
        font-size: 0.7rem;
        padding: 0.25rem 0.75rem;
        font-weight: 500;
    }
    .table-row-hover:hover {
        background-color: rgba(102, 126, 234, 0.05);
        transition: all 0.2s;
    }
    .quick-action-btn {
        transition: all 0.2s ease;
    }
    .quick-action-btn:hover {
        transform: translateY(-2px);
    }
</style>

<!-- Main Content -->
<main class="container mx-auto px-4 py-6">
    <!-- Welcome Banner -->
    <div class="gradient-bg rounded-2xl shadow-xl mb-8 overflow-hidden">
        <div class="p-6 md:p-8">
            <div class="flex flex-col md:flex-row justify-between items-start md:items-center">
                <div>
                    <h1 class="text-xl md:text-2xl font-bold text-white mb-2 flex items-center">
                        <i class="fas fa-hand-peace mr-3"></i>
                        Selamat Datang, <?= htmlspecialchars($current_user['nama']) ?>!
                    </h1>
                    <p class="text-white/80 flex items-center text-sm">
                        <i class="fas fa-calendar-alt mr-2"></i>
                        Tahun Ajaran: 
                        <span class="ml-2 bg-white/20 px-3 py-1 rounded-full text-xs">
                            <?= $tahun_ajaran ? htmlspecialchars($tahun_ajaran['tahun_ajaran']) . ' - Semester ' . ucfirst($tahun_ajaran['semester']) : 'Belum ada tahun ajaran aktif' ?>
                        </span>
                    </p>
                </div>
                <div class="mt-4 md:mt-0 bg-white/20 backdrop-blur-lg rounded-xl px-4 py-2 text-sm">
                    <i class="fas fa-clock mr-2"></i>
                    <?= date('l, d F Y') ?>
                </div>
            </div>
        </div>
    </div>

    <!-- Statistics Cards - Grid 2x2 untuk tampilan compact -->
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5 mb-8">
        <!-- Total Siswa -->
        <div class="stat-card bg-white rounded-xl p-5 shadow-sm">
            <div class="flex items-center justify-between">
                <div>
                    <p class="text-sm text-gray-500 mb-1">Total Siswa Aktif</p>
                    <h3 class="text-2xl font-bold text-gray-800"><?= number_format($total_siswa, 0, ',', '.') ?></h3>
                    <p class="text-xs text-green-600 mt-2">
                        <i class="fas fa-users mr-1"></i>Keseluruhan
                    </p>
                </div>
                <div class="bg-purple-100 p-3 rounded-xl">
                    <i class="fas fa-user-graduate text-xl text-purple-600"></i>
                </div>
            </div>
        </div>

        <!-- Konseling Aktif -->
        <div class="stat-card bg-white rounded-xl p-5 shadow-sm">
            <div class="flex items-center justify-between">
                <div>
                    <p class="text-sm text-gray-500 mb-1">Konseling Aktif</p>
                    <h3 class="text-2xl font-bold text-gray-800"><?= number_format($total_konseling, 0, ',', '.') ?></h3>
                    <p class="text-xs text-yellow-600 mt-2">
                        <i class="fas fa-clock mr-1"></i>Dalam proses
                    </p>
                </div>
                <div class="bg-green-100 p-3 rounded-xl">
                    <i class="fas fa-hand-holding-heart text-xl text-green-600"></i>
                </div>
            </div>
        </div>

        <!-- Laporan Baru -->
        <div class="stat-card bg-white rounded-xl p-5 shadow-sm">
            <div class="flex items-center justify-between">
                <div>
                    <p class="text-sm text-gray-500 mb-1">Laporan Baru</p>
                    <h3 class="text-2xl font-bold text-gray-800"><?= number_format($total_laporan, 0, ',', '.') ?></h3>
                    <p class="text-xs text-red-600 mt-2">
                        <i class="fas fa-exclamation-circle mr-1"></i>Perlu diproses
                    </p>
                </div>
                <div class="bg-yellow-100 p-3 rounded-xl">
                    <i class="fas fa-exclamation-triangle text-xl text-yellow-600"></i>
                </div>
            </div>
        </div>

        <!-- Pelanggaran -->
        <div class="stat-card bg-white rounded-xl p-5 shadow-sm">
            <div class="flex items-center justify-between">
                <div>
                    <p class="text-sm text-gray-500 mb-1">Pelanggaran Bulan Ini</p>
                    <h3 class="text-2xl font-bold text-gray-800"><?= number_format($total_pelanggaran, 0, ',', '.') ?></h3>
                    <p class="text-xs text-blue-600 mt-2">
                        <i class="fas fa-chart-line mr-1"></i>Perlu pembinaan
                    </p>
                </div>
                <div class="bg-blue-100 p-3 rounded-xl">
                    <i class="fas fa-ban text-xl text-blue-600"></i>
                </div>
            </div>
        </div>
    </div>

    <!-- Charts & Actions - Layout yang lebih seimbang -->
    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
        <!-- Grafik Konseling - Menggunakan Bar Chart -->
        <div class="lg:col-span-2 bg-white rounded-xl shadow-sm p-5">
            <div class="flex justify-between items-center mb-4">
                <div>
                    <h5 class="text-base font-semibold text-gray-800">
                        <i class="fas fa-chart-bar text-purple-600 mr-2"></i>
                        Statistik Konseling 6 Bulan Terakhir
                    </h5>
                    <p class="text-xs text-gray-500 mt-1">Jumlah sesi konseling per bulan</p>
                </div>
                <div class="relative group">
                    <button class="text-gray-400 hover:text-purple-600 transition text-sm">
                        <i class="fas fa-download mr-1"></i>Export
                    </button>
                </div>
            </div>
            <div class="chart-container">
                <canvas id="konselingChart"></canvas>
            </div>
        </div>

        <!-- Quick Actions -->
        <div class="bg-white rounded-xl shadow-sm p-5">
            <h5 class="text-base font-semibold text-gray-800 mb-4">
                <i class="fas fa-bolt text-yellow-500 mr-2"></i>
                Aksi Cepat
            </h5>
            <div class="grid grid-cols-2 gap-3">
                <a href="laporan/tambah.php" class="quick-action-btn flex flex-col items-center p-3 bg-purple-50 rounded-xl hover:bg-purple-100 transition group">
                    <i class="fas fa-flag text-lg text-purple-600 mb-1"></i>
                    <span class="text-xs font-medium text-gray-700">Buat Laporan</span>
                </a>
                <a href="jadwal/tambah.php" class="quick-action-btn flex flex-col items-center p-3 bg-green-50 rounded-xl hover:bg-green-100 transition group">
                    <i class="fas fa-calendar-plus text-lg text-green-600 mb-1"></i>
                    <span class="text-xs font-medium text-gray-700">Jadwal Konseling</span>
                </a>
                <a href="konseling/tambah.php" class="quick-action-btn flex flex-col items-center p-3 bg-blue-50 rounded-xl hover:bg-blue-100 transition group">
                    <i class="fas fa-comments text-lg text-blue-600 mb-1"></i>
                    <span class="text-xs font-medium text-gray-700">Sesi Konseling</span>
                </a>
                <a href="siswa/tambah.php" class="quick-action-btn flex flex-col items-center p-3 bg-yellow-50 rounded-xl hover:bg-yellow-100 transition group">
                    <i class="fas fa-user-plus text-lg text-yellow-600 mb-1"></i>
                    <span class="text-xs font-medium text-gray-700">Tambah Siswa</span>
                </a>
            </div>
        </div>
    </div>

    <!-- Tables Row - Laporan dan Jadwal -->
    <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
        <!-- Laporan Terbaru -->
        <div class="bg-white rounded-xl shadow-sm overflow-hidden">
            <div class="flex justify-between items-center p-5 border-b border-gray-100">
                <h5 class="text-base font-semibold text-gray-800">
                    <i class="fas fa-clipboard-list text-purple-600 mr-2"></i>
                    Laporan Masalah Terbaru
                </h5>
                <a href="laporan/" class="text-purple-600 hover:text-purple-700 text-xs font-medium">
                    Lihat Semua <i class="fas fa-arrow-right ml-1"></i>
                </a>
            </div>
            <div class="overflow-x-auto">
                <table class="w-full">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Tanggal</th>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Siswa</th>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
                            <th class="px-5 py-3 text-right text-xs font-medium text-gray-500 uppercase">Aksi</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-50">
                        <?php if (mysqli_num_rows($recent_laporan) > 0): ?>
                            <?php while($laporan = mysqli_fetch_assoc($recent_laporan)): ?>
                                <tr class="table-row-hover">
                                    <td class="px-5 py-3 text-xs text-gray-600">
                                        <i class="fas fa-calendar-alt text-gray-400 mr-1"></i>
                                        <?= htmlspecialchars($laporan['tgl_format']) ?>
                                    </td>
                                    <td class="px-5 py-3">
                                        <div class="flex items-center">
                                            <div class="w-6 h-6 bg-purple-100 rounded-full flex items-center justify-center mr-2">
                                                <i class="fas fa-user-circle text-purple-600 text-xs"></i>
                                            </div>
                                            <span class="text-sm"><?= htmlspecialchars($laporan['nama_siswa']) ?></span>
                                        </div>
                                    </td>
                                    <td class="px-5 py-3">
                                        <?php
                                        $badge_class = '';
                                        $badge_color = '';
                                        switch($laporan['status']) {
                                            case 'baru':
                                                $badge_class = 'bg-yellow-100 text-yellow-700';
                                                break;
                                            case 'diproses':
                                                $badge_class = 'bg-blue-100 text-blue-700';
                                                break;
                                            case 'selesai':
                                                $badge_class = 'bg-green-100 text-green-700';
                                                break;
                                        }
                                        ?>
                                        <span class="badge-custom <?= $badge_class ?> px-2 py-1 rounded-full text-xs">
                                            <?= ucfirst($laporan['status']) ?>
                                        </span>
                                    </td>
                                    <td class="px-5 py-3 text-right">
                                        <a href="laporan/detail.php?id=<?= $laporan['id_laporan'] ?>" 
                                           class="text-purple-600 hover:text-purple-800 text-sm">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                    </td>
                                </tr>
                            <?php endwhile; ?>
                        <?php else: ?>
                            <tr>
                                <td colspan="4" class="px-5 py-8 text-center text-gray-500">
                                    <i class="fas fa-inbox text-2xl mb-2 text-gray-300"></i>
                                    <p class="text-sm">Tidak ada laporan terbaru</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>

        <!-- Jadwal Hari Ini -->
        <div class="bg-white rounded-xl shadow-sm overflow-hidden">
            <div class="flex justify-between items-center p-5 border-b border-gray-100">
                <h5 class="text-base font-semibold text-gray-800">
                    <i class="fas fa-calendar-check text-green-600 mr-2"></i>
                    Jadwal Konseling Hari Ini
                </h5>
                <a href="jadwal/" class="text-purple-600 hover:text-purple-700 text-xs font-medium">
                    Lihat Semua <i class="fas fa-arrow-right ml-1"></i>
                </a>
            </div>
            <div class="overflow-x-auto">
                <table class="w-full">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Jam</th>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Siswa</th>
                            <th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
                            <th class="px-5 py-3 text-right text-xs font-medium text-gray-500 uppercase">Aksi</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-50">
                        <?php if (mysqli_num_rows($jadwal_hari_ini) > 0): ?>
                            <?php while($jadwal = mysqli_fetch_assoc($jadwal_hari_ini)): ?>
                                <tr class="table-row-hover">
                                    <td class="px-5 py-3 text-xs text-gray-600">
                                        <i class="fas fa-clock text-gray-400 mr-1"></i>
                                        <?= htmlspecialchars($jadwal['jam_format']) ?>
                                    </td>
                                    <td class="px-5 py-3">
                                        <span class="text-sm"><?= htmlspecialchars($jadwal['nama_siswa']) ?></span>
                                    </td>
                                    <td class="px-5 py-3">
                                        <?php
                                        $badge_class = '';
                                        switch($jadwal['status']) {
                                            case 'diajukan':
                                                $badge_class = 'bg-yellow-100 text-yellow-700';
                                                break;
                                            case 'disetujui':
                                                $badge_class = 'bg-green-100 text-green-700';
                                                break;
                                            case 'ditolak':
                                            case 'dibatalkan':
                                                $badge_class = 'bg-red-100 text-red-700';
                                                break;
                                            case 'selesai':
                                                $badge_class = 'bg-gray-100 text-gray-700';
                                                break;
                                        }
                                        ?>
                                        <span class="badge-custom <?= $badge_class ?> px-2 py-1 rounded-full text-xs">
                                            <?= ucfirst($jadwal['status']) ?>
                                        </span>
                                    </td>
                                    <td class="px-5 py-3 text-right">
                                        <a href="jadwal/detail.php?id=<?= $jadwal['id_jadwal'] ?>" 
                                           class="text-green-600 hover:text-green-800 text-sm">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                    </td>
                                </tr>
                            <?php endwhile; ?>
                        <?php else: ?>
                            <tr>
                                <td colspan="4" class="px-5 py-8 text-center text-gray-500">
                                    <i class="fas fa-calendar-times text-2xl mb-2 text-gray-300"></i>
                                    <p class="text-sm">Tidak ada jadwal hari ini</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- Prestasi Siswa - Compact version -->
    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
        <div class="flex justify-between items-center p-5 border-b border-gray-100">
            <h5 class="text-base font-semibold text-gray-800">
                <i class="fas fa-trophy text-yellow-500 mr-2"></i>
                Prestasi & Perkembangan Siswa
            </h5>
            <a href="perkembangan/" class="text-purple-600 hover:text-purple-700 text-xs font-medium">
                Lihat Semua <i class="fas fa-arrow-right ml-1"></i>
            </a>
        </div>
        <div class="p-5">
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
                <?php if (mysqli_num_rows($prestasi) > 0): ?>
                    <?php while($row = mysqli_fetch_assoc($prestasi)): ?>
                        <div class="flex items-center p-3 bg-purple-50 rounded-lg hover:shadow-sm transition">
                            <div class="bg-yellow-100 p-2 rounded-full mr-3">
                                <i class="fas fa-star text-yellow-600 text-sm"></i>
                            </div>
                            <div class="flex-1">
                                <h6 class="font-semibold text-gray-800 text-sm"><?= htmlspecialchars($row['nama_siswa']) ?></h6>
                                <p class="text-xs text-green-600 truncate"><?= htmlspecialchars($row['catatan']) ?></p>
                            </div>
                        </div>
                    <?php endwhile; ?>
                <?php else: ?>
                    <div class="col-span-3 text-center py-6 text-gray-500">
                        <i class="fas fa-medal text-2xl mb-2 text-gray-300"></i>
                        <p class="text-sm">Belum ada data prestasi</p>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</main>

<!-- Chart.js Script -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
    // Data dari PHP
    const labels = <?= json_encode($bulan_labels) ?>;
    const data = <?= json_encode($total_konseling_data) ?>;
    
    // Cek canvas element
    const canvas = document.getElementById('konselingChart');
    
    if (canvas) {
        const ctx = canvas.getContext('2d');
        
        // Buat Bar Chart yang elegan
        new Chart(ctx, {
            type: 'bar',
            data: {
                labels: labels,
                datasets: [{
                    label: 'Jumlah Konseling',
                    data: data,
                    backgroundColor: [
                        'rgba(102, 126, 234, 0.7)',
                        'rgba(102, 126, 234, 0.7)',
                        'rgba(102, 126, 234, 0.7)',
                        'rgba(102, 126, 234, 0.7)',
                        'rgba(102, 126, 234, 0.7)',
                        'rgba(102, 126, 234, 0.7)'
                    ],
                    borderColor: 'rgba(102, 126, 234, 1)',
                    borderWidth: 1,
                    borderRadius: 6,
                    barPercentage: 0.65,
                    categoryPercentage: 0.8
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        backgroundColor: '#1f2937',
                        titleColor: '#fff',
                        bodyColor: '#e5e7eb',
                        padding: 10,
                        cornerRadius: 8,
                        callbacks: {
                            label: function(context) {
                                return `Jumlah: ${context.raw} sesi`;
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        grid: {
                            color: 'rgba(0, 0, 0, 0.05)',
                            drawBorder: false
                        },
                        ticks: {
                            stepSize: 1,
                            font: {
                                size: 11
                            },
                            callback: function(value) {
                                return value;
                            }
                        },
                        title: {
                            display: true,
                            text: 'Jumlah Sesi',
                            font: {
                                size: 10,
                                weight: 'normal'
                            },
                            color: '#6b7280'
                        }
                    },
                    x: {
                        grid: {
                            display: false
                        },
                        ticks: {
                            font: {
                                size: 11,
                                weight: '500'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Bulan',
                            font: {
                                size: 10,
                                weight: 'normal'
                            },
                            color: '#6b7280'
                        }
                    }
                },
                layout: {
                    padding: {
                        left: 10,
                        right: 10,
                        top: 10,
                        bottom: 10
                    }
                }
            }
        });
    }
});

// Fungsi export chart (simulasi)
function exportChart(type) {
    alert('Fitur export ' + type + ' akan segera tersedia');
}
</script>

<?php
include '../includes/footer.php';
?>