<?php
session_start();
if (!isset($_SESSION['unohs'])) { header("Location: index.php"); exit(); }
include "conn.php";

$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $title = mysqli_real_escape_string($conn, $_POST['title'] ?? '');
    $content = mysqli_real_escape_string($conn, $_POST['content'] ?? '');
    $conn->query("UPDATE site_settings SET setting_value = '$title' WHERE setting_key = 'about_title'");
    $conn->query("UPDATE site_settings SET setting_value = '$content' WHERE setting_key = 'about_content'");
    $message = "✅ About Page Update হয়েছে।";
}

$row = $conn->query("SELECT setting_key, setting_value FROM site_settings WHERE setting_key IN ('about_title','about_content')");
$title = ''; $content = '';
while ($r = $row->fetch_assoc()) {
    if ($r['setting_key'] === 'about_title') $title = $r['setting_value'];
    if ($r['setting_key'] === 'about_content') $content = $r['setting_value'];
}
?>
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>Manage About Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
    body { background: #0A0A0A; color: #F5EFDC; font-family: sans-serif; padding: 20px; }
    .card { background: #171512; border: 1px solid #3A3226; border-radius: 14px; padding: 20px; max-width: 500px; }
    input, textarea { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #3A3226; background: #0A0A0A; color: #F5EFDC; font-size: 14px; margin: 8px 0; box-sizing: border-box; }
    textarea { min-height: 150px; }
    button { width: 100%; padding: 12px; border-radius: 8px; border: none; background: #D4AF37; color: #1A1400; font-weight: 700; cursor: pointer; }
</style></head>
<body>
<div class="card">
    <h3 style="color:#D4AF37;">📄 Manage About Page</h3>
    <?php if ($message): ?><p style="color:#1FB979;"><?= $message ?></p><?php endif; ?>
    <form method="POST">
        <label>Title</label>
        <input type="text" name="title" value="<?= htmlspecialchars($title) ?>">
        <label>Content</label>
        <textarea name="content"><?= htmlspecialchars($content) ?></textarea>
        <button type="submit">Save করো</button>
    </form>
</div>
</body></html>
