<h2 class="mb-4">Performa Vendor SLA</h2>

<div class="card shadow mb-4">
    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary">Laporan Performa Vendor</h6>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                <thead>
                    <tr>
                        <th>Nama Vendor</th>
                        <th>Jenis Layanan</th>
                        <th>SLA Uptime Target (%)</th>
                        <th>Uptime Aktual (%)</th>
                        <th>Perbedaan Uptime</th>
                        <th>SLA Respon Waktu Target (Menit)</th>
                        <th>Total Downtime (Menit)</th>
                        <th>Jumlah Insiden</th>
                        <th>Jumlah Pelanggaran SLA</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if (!empty($performanceData)): ?>
                        <?php foreach ($performanceData as $vendor): ?>
                            <tr>
                                <td><?php echo htmlspecialchars($vendor['nama_vendor']); ?></td>
                                <td><?php echo htmlspecialchars($vendor['jenis_layanan']); ?></td>
                                <td><?php echo htmlspecialchars($vendor['sla_uptime_percentage']); ?></td>
                                <td class="<?php echo ($vendor['actual_uptime_percentage'] < $vendor['sla_uptime_percentage']) ? 'text-danger fw-bold' : 'text-success'; ?>">
                                    <?php echo htmlspecialchars($vendor['actual_uptime_percentage']); ?>
                                </td>
                                <td>
                                    <?php 
                                        $uptimeDiff = $vendor['actual_uptime_percentage'] - $vendor['sla_uptime_percentage'];
                                        echo number_format($uptimeDiff, 2) . "%";
                                    ?>
                                </td>
                                <td><?php echo htmlspecialchars($vendor['sla_response_time_minutes']); ?></td>
                                <td><?php echo htmlspecialchars($vendor['total_downtime_minutes']); ?></td>
                                <td><?php echo htmlspecialchars($vendor['number_of_incidents']); ?></td>
                                <td class="<?php echo ($vendor['number_of_sla_breaches'] > 0) ? 'text-danger fw-bold' : ''; ?>">
                                    <?php echo htmlspecialchars($vendor['number_of_sla_breaches']); ?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="9" class="text-center">Tidak ada data performa vendor yang ditemukan.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>