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

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

// Ambil data guru dari database
$guru_data = null;
if($guru_id > 0) {
    $query_guru = mysqli_query($conn, "SELECT id, full_name, unit FROM users WHERE id = $guru_id AND role = 'Guru'");
    if($query_guru && mysqli_num_rows($query_guru) > 0) {
        $guru_data = mysqli_fetch_assoc($query_guru);
        $guru_nama = $guru_data['full_name'];
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Menu Supervisi - SIM ISTIQLAL</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-card {
            border-radius: 20px;
            transition: all 0.3s ease;
            height: 100%;
            background: white;
            box-shadow: 0 5px 20px rgba(0,0,0,0.08);
        }
        .form-card:hover { transform: translateY(-8px); box-shadow: 0 20px 40px rgba(0,0,0,0.15); }
        .form-icon { font-size: 48px; margin-bottom: 20px; }
        .card-body { text-align: center; padding: 30px; }
        .btn-form { margin-top: 15px; border-radius: 30px; padding: 8px 25px; }
        .badge-new { position: absolute; top: 15px; right: 15px; background: #f59e0b; color: white; padding: 3px 10px; border-radius: 20px; font-size: 11px; }
        .guru-info-card { background: linear-gradient(135deg, #e0f2fe 0%, #d9f9ff 100%); border-radius: 16px; padding: 15px 20px; margin-bottom: 25px; border-left: 4px solid #0b5e4e; }
    </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 font-weight-bold"><i class="fas fa-clipboard-list text-primary"></i> Instrumen Supervisi</h1>
                        <small>Pilih formulir supervisi yang akan diisi</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 active">Instrumen Supervisi</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content">
            <div class="container-fluid">
                
                <!-- Informasi Guru Terpilih -->
                <?php if($guru_nama): ?>
                <div class="guru-info-card">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <i class="fas fa-user-circle fa-2x text-success me-2"></i>
                            <strong>Mengisi formulir untuk guru:</strong> <?= htmlspecialchars($guru_nama) ?>
                            <?php if(isset($guru_data['unit'])): ?>
                                <span class="badge bg-secondary ms-2"><?= htmlspecialchars($guru_data['unit']) ?></span>
                            <?php endif; ?>
                            <br><small class="text-muted">Data guru akan otomatis terisi di formulir.</small>
                        </div>
                        <a href="supervisi_menu.php" class="btn btn-sm btn-outline-secondary"><i class="fas fa-times"></i> Ubah</a>
                    </div>
                </div>
                <?php else: ?>
                <div class="alert alert-info">
                    <i class="fas fa-info-circle"></i> 
                    Silakan pilih guru terlebih dahulu dari halaman <a href="../jadwal_supervisi.php" class="alert-link">Jadwal Supervisi</a>.
                </div>
                <?php endif; ?>

                <!-- Tombol Kembali -->
                <div class="mb-3">
                    <a href="../jadwal_supervisi.php" class="btn btn-secondary"><i class="fas fa-arrow-left"></i> Kembali ke Jadwal Supervisi</a>
                </div>

                <div class="row">
                    <!-- Card 1: Telaah RPP -->
                    <div class="col-md-4 mb-4">
                        <div class="card form-card">
                            <div class="card-body">
                                <span class="badge-new">Wajib</span>
                                <div class="form-icon text-primary"><i class="fas fa-book-open"></i></div>
                                <h5>FORMULIR INSTRUMEN</h5>
                                <h4 class="text-primary">TELAAH RPP/MODUL AJAR</h4>
                                <p class="text-muted small">Instrumen untuk menelaah kelengkapan dan kualitas RPP/Modul Ajar</p>
                                <a href="form_rpp.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-primary btn-form">
                                    <i class="fas fa-edit"></i> Isi Formulir
                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Card 2: Pelaksanaan Supervisi -->
                    <div class="col-md-4 mb-4">
                        <div class="card form-card">
                            <div class="card-body">
                                <span class="badge-new">Wajib</span>
                                <div class="form-icon text-success"><i class="fas fa-chalkboard-teacher"></i></div>
                                <h5>FORMULIR INSTRUMEN</h5>
                                <h4 class="text-success">PELAKSANAAN SUPERVISI AKADEMIK</h4>
                                <p class="text-muted small">Instrumen observasi pelaksanaan pembelajaran di kelas</p>
                                <a href="form_pelaksanaan.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-success btn-form">
                                    <i class="fas fa-edit"></i> Isi Formulir
                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Card 3: Wawancara -->
                    <div class="col-md-4 mb-4">
                        <div class="card form-card">
                            <div class="card-body">
                                <div class="form-icon text-info"><i class="fas fa-comments"></i></div>
                                <h5>FORMULIR INSTRUMEN</h5>
                                <h4 class="text-info">WAWANCARA PASCA SUPERVISI</h4>
                                <p class="text-muted small">Instrumen wawancara refleksi setelah supervisi</p>
                                <a href="form_wawancara.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-info btn-form">
                                    <i class="fas fa-edit"></i> Isi Formulir
                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Card 4: Perbaikan -->
                    <div class="col-md-4 mb-4">
                        <div class="card form-card">
                            <div class="card-body">
                                <div class="form-icon text-warning"><i class="fas fa-tools"></i></div>
                                <h5>FORMULIR</h5>
                                <h4 class="text-warning">PERMINTAAN TINDAKAN PERBAIKAN</h4>
                                <p class="text-muted small">Formulir permintaan tindakan perbaikan hasil supervisi</p>
                                <a href="form_perbaikan.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-warning btn-form">
                                    <i class="fas fa-edit"></i> Isi Formulir
                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Card 5: Pencegahan -->
                    <div class="col-md-4 mb-4">
                        <div class="card form-card">
                            <div class="card-body">
                                <div class="form-icon text-danger"><i class="fas fa-shield-alt"></i></div>
                                <h5>FORMULIR</h5>
                                <h4 class="text-danger">TINDAKAN PENCEGAHAN</h4>
                                <p class="text-muted small">Formulir tindakan pencegahan untuk perbaikan ke depan</p>
                                <a href="form_pencegahan.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-danger btn-form">
                                    <i class="fas fa-edit"></i> Isi Formulir
                                </a>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Petunjuk -->
                <div class="row mt-4">
                    <div class="col-12">
                        <div class="alert alert-info">
                            <i class="fas fa-info-circle"></i>
                            <strong>Petunjuk:</strong>
                            <ol class="mt-2 mb-0">
                                <li>Pilih guru dari <strong>Jadwal Supervisi</strong> terlebih dahulu</li>
                                <li>Klik tombol <strong>"Formulir"</strong> pada jadwal yang diinginkan</li>
                                <li>Pilih jenis formulir supervisi</li>
                                <li>Data guru akan otomatis terisi</li>
                                <li>Isi data, lalu klik <strong>"Simpan & Cetak PDF"</strong></li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <footer class="main-footer"><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>
</body>
</html>