<?php 
include '../koneksi.php';
cek_akses(['Kepala', 'Super Admin']);

// Ambil parameter dari URL (dikirim dari supervisi_menu.php)
$guru_id = isset($_GET['guru_id']) ? (int)$_GET['guru_id'] : 0;
$guru_nama = isset($_GET['guru_nama']) ? urldecode($_GET['guru_nama']) : '';

// Jika ada guru_id tapi nama kosong, ambil dari database
if($guru_id > 0 && empty($guru_nama)) {
    $query_guru = mysqli_query($conn, "SELECT full_name FROM users WHERE id = $guru_id AND role = 'Guru'");
    if($query_guru && mysqli_num_rows($query_guru) > 0) {
        $guru = mysqli_fetch_assoc($query_guru);
        $guru_nama = $guru['full_name'];
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Formulir Pelaksanaan Supervisi Akademik</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/theme-istiqlal-green.css">
    <style>
        .form-container { max-width: 1400px; margin: 0 auto; }
        .section-card { margin-bottom: 20px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
        .section-header { background: #0b5e4e; color: white; padding: 10px 15px; font-weight: 600; }
        .section-body { background: white; padding: 15px; }
        .item-row { border-bottom: 1px solid #e2e8f0; padding: 12px 0; }
        .item-row:last-child { border-bottom: none; }
        .item-number { font-weight: 700; color: #0b5e4e; width: 35px; display: inline-block; }
        .item-text { display: inline-block; width: calc(100% - 350px); vertical-align: top; }
        .rating-group { display: inline-flex; gap: 15px; margin-left: 15px; align-items: center; }
        .rating-option { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }
        .rating-option input { margin: 0; transform: scale(1.1); }
        .catatan-field { margin-top: 8px; margin-left: 35px; }
        .catatan-field input { width: 100%; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12px; }
        @media print { .no-print { display: none !important; } }
    </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
    <?php include '../sidebar.php'; ?>
    
    <div class="content-wrapper">
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0" style="font-size: 18px;"><i class="fas fa-chalkboard-teacher text-success"></i> FORMULIR INSTRUMEN</h1>
                        <small>PELAKSANAAN SUPERVISI AKADEMIK (F-037-KM)</small>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="../dashboard.php">Home</a></li>
                            <li class="breadcrumb-item"><a href="supervisi_menu.php">Supervisi</a></li>
                            <li class="breadcrumb-item active">Pelaksanaan Supervisi</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content">
            <div class="container-fluid form-container">
                <form method="POST" action="cetak_dokumen.php" target="_blank" id="formPelaksanaan">
                    <input type="hidden" name="form_type" value="pelaksanaan">
                    
                    <!-- Data Guru -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-user"></i> Data Guru</div>
                        <div class="section-body">
                            <div class="row">
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Nama Guru</label>
                                    <input type="text" name="nama_guru" class="form-control form-control-sm" value="<?= htmlspecialchars($guru_nama) ?>" required>
                                    <?php if($guru_nama): ?>
                                    <small class="text-success d-block">✓ Data otomatis dari jadwal supervisi</small>
                                    <?php endif; ?>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Bidang Studi</label>
                                    <input type="text" name="bidang_studi" class="form-control form-control-sm" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Kelas</label>
                                    <input type="text" name="kelas" class="form-control form-control-sm" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Tanggal/Waktu</label>
                                    <input type="text" name="tanggal_waktu" class="form-control form-control-sm" placeholder="25 Mei 2024 / 07:30" required>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- A. Apersepsi dan Motivasi (1-4) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-lightbulb"></i> A. Apersepsi dan Motivasi</div>
                        <div class="section-body">
                            <?php
                            $apersepsi = [
                                1 => 'Mengaitkan materi pembelajaran sekarang dengan pengalaman peserta didik atau pembelajaran sebelumnya.',
                                2 => 'Mengajukan pertanyaan menantang.',
                                3 => 'Menyampaikan manfaat materi pembelajaran.',
                                4 => 'Mendemonstrasikan sesuatu yang terkait dengan materi pembelajaran.'
                            ];
                            foreach($apersepsi as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- B. Penyampaian Kompetensi (5-6) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-bullseye"></i> B. Penyampaian Kompetensi dan Rencana Kegiatan</div>
                        <div class="section-body">
                            <?php
                            $kompetensi = [
                                5 => 'Menyampaikan kemampuan yang akan dicapai peserta didik.',
                                6 => 'Menyampaikan rencana kegiatan (individual, kerja kelompok, observasi).'
                            ];
                            foreach($kompetensi as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- C. Penguasaan Materi (7-10) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-book"></i> C. Kegiatan Inti - Penguasaan Materi Pelajaran</div>
                        <div class="section-body">
                            <?php
                            $materi = [
                                7 => 'Kemampuan menyesuaikan materi dengan tujuan pembelajaran.',
                                8 => 'Kemampuan mengkaitkan materi dengan pengetahuan lain yang relevan.',
                                9 => 'Menyajikan pembahasan materi pembelajaran dengan tepat.',
                                10 => 'Menyajikan materi secara sistematis (mudah ke sulit, konkrit ke abstrak).'
                            ];
                            foreach($materi as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- D. Strategi Pembelajaran (11-17) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-chalkboard"></i> Penerapan Strategi Pembelajaran yang Mendidik</div>
                        <div class="section-body">
                            <?php
                            $strategi = [
                                11 => 'Melaksanakan pembelajaran sesuai dengan kompetensi yang akan dicapai.',
                                12 => 'Menfasilitasi kegiatan yang memuat eksplorasi, elaborasi dan konfirmasi.',
                                13 => 'Melaksanakan pembelajaran secara runtut.',
                                14 => 'Menguasai kelas.',
                                15 => 'Melaksanakan pembelajaran yang bersifat kontekstual.',
                                16 => 'Melaksanakan pembelajaran yang memungkinkan tumbuhnya kebiasaan positif.',
                                17 => 'Melaksanakan pembelajaran sesuai dengan alokasi waktu yang direncanakan.'
                            ];
                            foreach($strategi as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- E. Pendekatan Scientific (18-24) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-flask"></i> Penerapan Pendekatan Scientific</div>
                        <div class="section-body">
                            <?php
                            $scientific = [
                                18 => 'Memberikan pertanyaan mengapa dan bagaimana.',
                                19 => 'Memfasilitasi peserta didik untuk mengamati.',
                                20 => 'Memancing peserta didik untuk bertanya.',
                                21 => 'Memfasilitasi peserta didik untuk mencoba.',
                                22 => 'Memfasilitasi peserta didik untuk menganalisis.',
                                23 => 'Memberikan pertanyaan peserta didik untuk menalar.',
                                24 => 'Menyajikan kegiatan peserta didik untuk berkomunikasi.'
                            ];
                            foreach($scientific as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- F. Pemanfaatan Media (25-29) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-tv"></i> Pemanfaatan Sumber Belajar/Media dalam Pembelajaran</div>
                        <div class="section-body">
                            <?php
                            $media = [
                                25 => 'Menunjukkan keterampilan dalam penggunaan sumber belajar.',
                                26 => 'Menunjukkan keterampilan dalam penggunaan media pembelajaran.',
                                27 => 'Menghasilkan pesan yang menarik.',
                                28 => 'Melibatkan peserta didik dalam pemanfaatan sumber belajar.',
                                29 => 'Melibatkan peserta didik dalam pemanfaatan media pembelajaran.'
                            ];
                            foreach($media as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- G. Pelibatan Peserta Didik (30-34) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-users"></i> Pelibatan Peserta Didik dalam Pembelajaran</div>
                        <div class="section-body">
                            <?php
                            $pelibatan = [
                                30 => 'Menumbuhkan partisipasi aktif peserta didik.',
                                31 => 'Merespon positif partisipasi peserta didik.',
                                32 => 'Menunjukkan sikap terbuka terhadap respons peserta didik.',
                                33 => 'Menunjukkan hubungan antar pribadi yang kondusif.',
                                34 => 'Menumbuhkan keceriaan atau antusiasme peserta didik dalam belajar.'
                            ];
                            foreach($pelibatan as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- H. Penilaian Autentik (35-37) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-clipboard-list"></i> Melaksanakan Penilaian Autentik</div>
                        <div class="section-body">
                            <?php
                            $penilaian = [
                                35 => 'Menilai sikap dalam pembelajaran.',
                                36 => 'Menilai pengetahuan dalam proses pembelajaran.',
                                37 => 'Menilai keterampilan dalam proses pembelajaran.'
                            ];
                            foreach($penilaian as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- I. Penggunaan Bahasa (38-39) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-language"></i> Penggunaan Bahasa yang Benar dan Tepat</div>
                        <div class="section-body">
                            <?php
                            $bahasa = [
                                38 => 'Menggunakan bahasa lisan secara jelas dan lancar.',
                                39 => 'Menggunakan bahasa tulis yang baik dan benar.'
                            ];
                            foreach($bahasa as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- J. Penutup (40-42) -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-check-circle"></i> Penutup Pembelajaran</div>
                        <div class="section-body">
                            <?php
                            $penutup = [
                                40 => 'Melakukan refleksi atau membuat rangkuman dengan melibatkan peserta didik.',
                                41 => 'Mengumpulkan hasil kerja sebagai bahan portofolio.',
                                42 => 'Melaksanakan tindak lanjut dengan memberikan arahan kegiatan berikutnya.'
                            ];
                            foreach($penutup as $no => $text): ?>
                            <div class="item-row">
                                <div>
                                    <span class="item-number"><?= $no ?></span>
                                    <span class="item-text"><?= $text ?></span>
                                    <div class="rating-group">
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="1" class="skor-radio"> 1</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="2" class="skor-radio"> 2</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="3" class="skor-radio"> 3</label>
                                        <label class="rating-option"><input type="radio" name="skor<?= $no ?>" value="4" class="skor-radio"> 4</label>
                                    </div>
                                </div>
                                <div class="catatan-field">
                                    <input type="text" name="catatan<?= $no ?>" class="form-control form-control-sm" placeholder="Catatan...">
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <!-- Ringkasan Skor -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-calculator"></i> Ringkasan Penilaian</div>
                        <div class="section-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <label class="small fw-bold">Jumlah Skor</label>
                                    <input type="text" name="total_skor" id="totalSkor" class="form-control form-control-sm" readonly style="background:#e9ecef">
                                </div>
                                <div class="col-md-3">
                                    <label class="small fw-bold">Skor Maksimal</label>
                                    <input type="text" class="form-control form-control-sm" value="168" readonly style="background:#e9ecef">
                                </div>
                                <div class="col-md-3">
                                    <label class="small fw-bold">Nilai Akhir</label>
                                    <input type="text" name="nilai_akhir" id="nilaiAkhir" class="form-control form-control-sm" readonly style="background:#e9ecef">
                                </div>
                                <div class="col-md-3">
                                    <label class="small fw-bold">Kriteria</label>
                                    <input type="text" name="kriteria" id="kriteria" class="form-control form-control-sm" readonly style="background:#e9ecef">
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Kesimpulan, Refleksi, Rekomendasi -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-clipboard-list"></i> Kesimpulan, Refleksi & Rekomendasi</div>
                        <div class="section-body">
                            <div class="mb-2">
                                <label class="small fw-bold">Kesimpulan</label>
                                <textarea name="kesimpulan" class="form-control form-control-sm" rows="2"></textarea>
                            </div>
                            <div class="mb-2">
                                <label class="small fw-bold">Refleksi</label>
                                <textarea name="refleksi" class="form-control form-control-sm" rows="2"></textarea>
                            </div>
                            <div class="mb-2">
                                <label class="small fw-bold">Rekomendasi</label>
                                <textarea name="rekomendasi" class="form-control form-control-sm" rows="2"></textarea>
                            </div>
                        </div>
                    </div>

                    <!-- Tanda Tangan -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-signature"></i> Tanda Tangan</div>
                        <div class="section-body">
                            <div class="row">
                                <div class="col-md-4">
                                    <label class="small fw-bold">Jakarta, tanggal</label>
                                    <input type="text" name="tanggal_ttd" class="form-control form-control-sm" placeholder="12 Agustus 2022" required>
                                </div>
                                <div class="col-md-4">
                                    <label class="small fw-bold">Penilai / Supervisor</label>
                                    <input type="text" name="supervisor" class="form-control form-control-sm" value="<?= $_SESSION['full_name'] ?>" readonly>
                                </div>
                                <div class="col-md-4">
                                    <label class="small fw-bold">NIP</label>
                                    <input type="text" name="nip" class="form-control form-control-sm" placeholder="Nomor Induk Pegawai">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="text-center mb-4 no-print">
                        <button type="submit" class="btn btn-success btn-sm"><i class="fas fa-file-pdf"></i> Simpan & Cetak PDF</button>
                        <button type="button" class="btn btn-secondary btn-sm" onclick="window.print()"><i class="fas fa-print"></i> Print</button>
                        <a href="supervisi_menu.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-outline-secondary btn-sm">
                            <i class="fas fa-arrow-left"></i> Kembali
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <footer class="main-footer no-print"><strong>&copy; <?= date('Y') ?> SIM ISTIQLAL</strong></footer>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
$(document).ready(function() {
    $('.skor-radio').on('change', function() { hitungSkor(); });
    
    function hitungSkor() {
        var total = 0;
        for(var i=1; i<=42; i++) {
            var skor = $('input[name="skor'+i+'"]:checked').val();
            if(skor) total += parseInt(skor);
        }
        $('#totalSkor').val(total);
        var nilaiAkhir = (total / 168) * 100;
        $('#nilaiAkhir').val(nilaiAkhir.toFixed(2));
        var kriteria = '';
        if(nilaiAkhir >= 86) kriteria = 'Amat Baik';
        else if(nilaiAkhir >= 70) kriteria = 'Baik';
        else kriteria = 'Kurang';
        $('#kriteria').val(kriteria);
    }
});
</script>
</body>
</html>