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

$query = "SELECT * FROM tb_struktur_sekolah";
$result = mysqli_query($host, $query);
$row = mysqli_fetch_assoc($result);
$current_image = htmlspecialchars($row['gambar']);
?>
<!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>Edit Struktur Organisasi</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: 900px;
            margin: 50px 10% 20px auto;
            padding: 30px;
            background: #fff;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            position: relative;
        }
        .container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 5px;
            background: linear-gradient(90deg, #0037fd, #5b8cffff);
            border-radius: 15px 15px 0 0;
        }
        h1 {
            text-align: center;
            color: #0037fd;
            margin-bottom: 30px;
            font-size: 28px;
            font-weight: bold;
        }
        .form-group {
            margin-bottom: 25px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #333;
            font-size: 16px;
        }
        .current-image {
            max-width: 300px;
            margin-bottom: 20px;
            border: 2px solid #ddd;
            border-radius: 8px;
        }
        input[type="file"] {
            width: 100%;
            padding: 10px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-size: 14px;
        }
        button {
            background: linear-gradient(135deg, #0037fd, #5b8cffff);
            color: #fff;
            padding: 12px 30px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s ease;
            display: block;
            margin: 0 0 0 auto;
        }
        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,55,253,0.4);
        }
        .breadcrumb {
            margin: 20px 10% 10px auto;
            max-width: 900px;
            font-size: 14px;
            color: #666;
        }
        .breadcrumb a {
            color: #0037fd;
            text-decoration: none;
        }
        .breadcrumb a:hover {
            text-decoration: underline;
        }
        .breadcrumb span {
            color: #333;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <?php include 'navbar_admin.php'; ?>
    <div class="breadcrumb">
        <a href="dashboard_admin.php">Dashboard</a> > <a href="profil_admin.php">Profil</a> > <span>Edit Struktur Organisasi</span>
    </div>
    <div class="container">
        <h1>Edit Struktur Organisasi</h1>
        <form action="update_struktur.php" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label>Gambar Struktur Organisasi Saat Ini:</label>
                <img src="upload/<?php echo $current_image; ?>" alt="Struktur Organisasi" class="current-image">
            </div>
            <div class="form-group">
                <label for="gambar">Pilih Gambar Baru:</label>
                <input type="file" id="gambar" name="gambar" accept="image/*" required>
            </div>
            <button type="submit">Update Gambar</button>
        </form>
    </div>
</body>
</html>

