<?php include 'koneksi.php';
session_start();
if (!isset($_SESSION['login_admin'])) {
    header('Location: dashboard.php');
    exit;
}

if (!isset($_GET['id'])) {
    header('Location: manage_jurusan.php');
    exit;
}

$id = intval($_GET['id']);
$query = "SELECT * FROM tb_jurusan WHERE id_jurusan = $id";
$result = mysqli_query($host, $query);

if (!$result || mysqli_num_rows($result) == 0) {
    header('Location: manage_jurusan.php');
    exit;
}

$row = mysqli_fetch_assoc($result);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $delete_query = "DELETE FROM tb_jurusan WHERE id_jurusan = $id";
    if (mysqli_query($host, $delete_query)) {
        echo "<script>alert('Jurusan berhasil dihapus!'); window.location.href='manage_jurusan.php';</script>";
    } else {
        echo "<script>alert('Error: " . mysqli_error($host) . "');</script>";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head><link rel="icon" href="upload/bn2.png" type="image/png">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hapus Jurusan | SMK Budiniah 2</title>
    <link rel="stylesheet" href="style_admin.css">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            min-height: 100vh;
        }
        .container {
            max-width: 600px;
            margin: 50px auto;
            padding: 30px;
            background: #fff;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        h1 {
            text-align: center;
            color: #dc3545;
            margin-bottom: 30px;
            font-size: 28px;
            font-weight: bold;
        }
        .jurusan-info {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 30px;
        }
        .jurusan-name {
            font-size: 20px;
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
        }
        .jurusan-desc {
            color: #666;
            line-height: 1.5;
        }
        .warning {
            background: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
            text-align: center;
        }
        .btn {
            background: linear-gradient(135deg, #dc3545, #c82333);
            color: #fff;
            padding: 12px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(220,53,69,0.4);
        }
        .btn-secondary {
            background: #6c757d;
            margin-left: 10px;
        }
        .btn-secondary:hover {
            background: #5a6268;
        }
        .form-actions {
            text-align: center;
            margin-top: 30px;
        }
    </style>
</head>
<body>
    <?php include 'navbar_admin.php'; ?>
    <div class="container">
        <h1>Hapus Jurusan</h1>
        <div class="warning">
            <strong>Perhatian!</strong> Tindakan ini tidak dapat dibatalkan. Jurusan yang dihapus akan hilang secara permanen.
        </div>
        <div class="jurusan-info">
            <div class="jurusan-name"><?php echo htmlspecialchars($row['nama_jurusan']); ?></div>
            <div class="jurusan-desc"><?php echo htmlspecialchars($row['deksripsi']); ?></div>
        </div>
        <form method="POST">
            <div class="form-actions">
                <button type="submit" class="btn">Ya, Hapus Jurusan</button>
                <a href="manage_jurusan.php" class="btn btn-secondary">Batal</a>
            </div>
        </form>
    </div>
</body>
</html>

