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

// Fetch current data
$query = "SELECT * FROM sekolah";
$result = mysqli_query($host, $query);
$row = mysqli_fetch_assoc($result);
$nama_sekolah = htmlspecialchars($row['nama_sekolah']);
$slogan_sekolah = htmlspecialchars($row['slogan_sekolah']);
$logo_sekolah = htmlspecialchars($row['logo_sekolah']);
?>
<!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>Rebranding Sekolah</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 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;
        }
        input[type="text"], input[type="file"] {
            width: 100%;
            padding: 15px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-family: 'Arial', sans-serif;
            font-size: 14px;
            transition: border-color 0.3s ease;
        }
        input[type="text"]:focus, input[type="file"]:focus {
            outline: none;
            border-color: #0037fd;
            box-shadow: 0 0 5px rgba(0,55,253,0.3);
        }
        .current-logo {
            margin-top: 10px;
            max-width: 200px;
            border-radius: 8px;
        }
        .button 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 auto;
        }
        .button button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,55,253,0.4);
        }
        .success-message {
            background: #d4edda;
            color: #155724;
            padding: 10px;
            border-radius: 5px;
            margin-bottom: 20px;
            text-align: center;
        }
        .breadcrumb {
            margin: 20px 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;
        }
        @media (max-width: 768px) {
            .container {
                max-width: 500px;
                margin: 20px 20px 0 80px;
                padding: 20px 5%;
            }
            h1 {
                font-size: 24px;
            }
            label {
                font-size: 14px;
            }
            input[type="text"], input[type="file"] {
                padding: 12px;
            }
            button {
                padding: 10px 20px;
                font-size: 14px;
            }
            .breadcrumb {
                margin: 20px 20px 0 80px;
                font-size: 12px;
                margin-bottom: 10px;
            }
        }
    </style>
</head>
<body>
    <?php include 'navbar_admin.php'; ?>
    <div class="breadcrumb">
        <a href="dashboard_admin.php">Dashboard</a> > <span>Rebranding Sekolah</span>
    </div>
    <div class="container">
        <h1>Rebranding Sekolah</h1>
        <form action="update_namasekolah.php" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="nama_sekolah">Nama Sekolah:</label>
                <input type="text" id="nama_sekolah" name="nama_sekolah" value="<?php echo $nama_sekolah; ?>" required>
            </div>
            <div class="form-group">
                <label for="slogan_sekolah">Slogan Sekolah:</label>
                <input type="text" id="slogan_sekolah" name="slogan_sekolah" value="<?php echo $slogan_sekolah; ?>" required>
            </div>
            <div class="form-group">
                <label for="logo_sekolah">Logo Sekolah:</label>
                <input type="file" id="logo_sekolah" name="logo_sekolah" accept="image/*">
                <p>Logo saat ini:</p>
                <img src="upload/<?php echo $logo_sekolah; ?>" alt="Logo Sekolah" class="current-logo">
            </div>
            <div class="button">
            <button type="submit">Update</button>
            </div>
        </form>
    </div>
</body>
</html>
