<?php
include "../config/db.php";

$data = mysqli_fetch_assoc(mysqli_query(
    $con,
    "SELECT * FROM site_content WHERE section_name='about'"
));
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Edit About</title>

    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: Arial, sans-serif;
        }

        body {
            background: #f4f7fc;
            padding: 40px;
        }

        .container {
            width: 90%;
            max-width: 1000px;
            margin: auto;
            background: white;
            padding: 40px;
            border-radius: 12px;
            box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.1);
        }

        h2 {
            margin-bottom: 30px;
            color: #333;
            text-align: center;
            font-size: 32px;
        }

        .form-group {
            margin-bottom: 25px;
        }

        label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
            color: #444;
            font-size: 18px;
        }

        input[type="text"],
        textarea,
        input[type="file"] {
            width: 100%;
            padding: 15px;
            border: 1px solid #ccc;
            border-radius: 8px;
            font-size: 17px;
        }

        textarea {
            min-height: 220px;
            resize: vertical;
        }

        .preview-image {
            margin-top: 15px;
        }

        .preview-image img {
            width: 250px;
            border-radius: 10px;
            border: 1px solid #ddd;
            padding: 5px;
        }

        button {
            background: #4a57a8;
            color: white;
            border: none;
            padding: 15px 40px;
            font-size: 18px;
            border-radius: 8px;
            cursor: pointer;
            transition: 0.3s;
        }

        button:hover {
            background: #39458f;
        }

        .btn-area {
            text-align: center;
            margin-top: 30px;
        }

        @media(max-width:768px) {
            .container {
                width: 100%;
                padding: 20px;
            }

            h2 {
                font-size: 26px;
            }
        }
    </style>
</head>

<body>

    <div class="container">

        <h2>Edit About Section</h2>

        <form action="update_about.php" method="POST" enctype="multipart/form-data">

            <input type="hidden" name="id" value="<?php echo $data['id']; ?>">

            <div class="form-group">
                <label>Title</label>

                <input type="text"
                    name="title"
                    value="<?php echo $data['title']; ?>">
            </div>

            <div class="form-group">
                <label>Description</label>

                <textarea name="description"><?php echo $data['description']; ?></textarea>
            </div>

            <div class="form-group">
                <label>Upload New Image</label>

                <input type="file" name="image">

                <div class="preview-image">
                    <p style="margin-bottom:10px;">Current Image:</p>

                    <img src="../uploads/<?php echo $data['image']; ?>" alt="">
                </div>
            </div>

            <div class="btn-area">
                <button type="submit">Update About Section</button>
            </div>

        </form>

    </div>

</body>

</html>