<?php include __DIR__ . '/../layout/header.php'; ?>

<div class="admin-card" style="width: 100%;">
    <div class="admin-card-header">
        <h2 class="admin-card-title">Sayfa Düzenle: <?php echo htmlspecialchars(isset($page->title) ? $page->title : ''); ?></h2>
    </div>
    
    <form action="<?php echo $baseUrl; ?>/admin/pages/update/<?php echo $page->id; ?>" method="POST">
        <div class="admin-form-group">
            <label for="title">Sayfa Başlığı</label>
            <input type="text" id="title" name="title" value="<?php echo htmlspecialchars(isset($page->title) ? $page->title : ''); ?>" required class="admin-input">
        </div>
        
        <div class="admin-form-group">
            <label for="content">Sayfa İçeriği</label>
            <textarea id="content" name="content" rows="15" class="admin-textarea"><?php echo htmlspecialchars(isset($page->content) ? $page->content : ''); ?></textarea>
        </div>
        
        <div style="display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px;">
            <a href="<?php echo $baseUrl; ?>/admin/pages" class="admin-btn">İptal</a>
            <button type="submit" class="admin-btn admin-btn-primary"><i class="fa fa-save" style="margin-right: 8px;"></i> Değişiklikleri Kaydet</button>
        </div>
    </form>
</div>

<!-- TinyMCE Integration -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.3/tinymce.min.js" referrerpolicy="origin"></script>
<script>
  tinymce.init({
    selector: '#content',
    plugins: 'advlist autolink lists link image charmap preview anchor pagebreak code',
    toolbar_mode: 'floating',
    height: 500,
    menubar: false,
    branding: false,
    promotion: false,
    toolbar: 'undo redo | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code',
    content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: #111827; }'
  });
</script>

<?php include __DIR__ . '/../layout/footer.php'; ?>
