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

$id_organisasi = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id_organisasi <= 0) {
    header('Location: manage_organisasi.php');
    exit;
}

$query = "SELECT * FROM tb_organisasi WHERE id_organisasi = $id_organisasi";
$result = mysqli_query($host, $query);
if (!$result || mysqli_num_rows($result) == 0) {
    header('Location: manage_organisasi.php');
    exit;
}
$row = mysqli_fetch_assoc($result);
$nama = htmlspecialchars($row['nama']);
$gambar = htmlspecialchars($row['gambar']);
$kategori = htmlspecialchars($row['kategori']);
?>

<!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>Detail Organisasi | 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: 800px;
            margin: 50px auto;
            padding: 30px;
            background: #fff;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        .back-btn {
            background: linear-gradient(135deg, #0037fd, #5b8cffff);
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            font-weight: bold;
            text-decoration: none;
            margin-bottom: 20px;
            display: inline-block;
        }
        .back-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,55,253,0.4);
        }
        .organisasi-detail {
            text-align: center;
        }
        .organisasi-detail img {
            width: 100%;
            max-width: 600px;
            height: auto;
            border-radius: 10px;
            margin-bottom: 20px;
        }
        .organisasi-detail h1 {
            color: #0037fd;
            margin-bottom: 20px;
            font-size: 28px;
        }
        .organisasi-detail p {
            color: #666;
            line-height: 1.6;
            font-size: 16px;
        }

        /* Responsive Design */
        @media (max-width: 768px) {
            .container {
                margin: 30px 5% 40px 15%;
                padding: 20px;
            }
            .organisasi-detail img {
                max-width: 90%;
                height: auto;
            }
            .organisasi-detail h1 {
                font-size: 24px;
            }
            .organisasi-detail p {
                font-size: 14px;
            }
        }

        @media (max-width: 480px) {
            .container {
                margin: 20px 5% 40px 15%;
                padding: 15px;
            }
            .back-btn {
                padding: 8px 16px;
                font-size: 12px;
            }
            .organisasi-detail h1 {
                font-size: 20px;
            }
            .organisasi-detail p {
                font-size: 12px;
            }
        }
    </style>
</head>
<body>
    <?php include 'navbar_admin.php'; ?>
    <div class="container">
        <a href="manage_organisasi.php" class="back-btn">← Kembali ke Manage Organisasi</a>
        <div class="organisasi-detail">
            <?php
            $imgSrc = !empty($gambar) ? "upload/" . $gambar : "upload/default.jpg";
            echo "<img src='" . $imgSrc . "' alt='" . $nama . "'>";
            echo "<h1>" . $nama . "</h1>";
            echo "<p><strong>Kategori:</strong> " . $kategori . "</p>";
            ?>
        </div>
    </div>
</body>
</html>

