<?php

/**
 * @var $csrf_token
 * @var \Guestbook\Models\Guestbook $message
 * @var $errors
 */

$this->layout('system::layout/default'); ?>

<div class="max-w-2xl mx-auto p-4">
    <h4 class="text-xl font-bold mb-6 text-gray-800 dark:text-gray-200"><?= __('Reply') ?></h4>
    
    <?php if (! empty($errors['csrf_token'])): ?>
        <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
            <?= implode(', ', $errors['csrf_token']) ?>
        </div>
    <?php endif ?>
    
    <form action="/guestbook/otvet?id=<?= $id ?>" method="post" class="space-y-6">
        <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"/>
        
        <div class="bg-gray-50 dark:bg-gray-800 p-4 rounded-lg">
            <p class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"><?= __('Author') ?>:</p>
            <p class="text-lg text-gray-900 dark:text-white font-semibold mb-3"><?= $message->name ?></p>
            <div class="text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 p-3 rounded border">
                <?= $message->post_text ?>
            </div>
        </div>
        
        <div>
            <?= $this->fetch(
                'guestbook::ckeditor',
                [
                    'label'  => __('Reply'),
                    'errors' => implode(', ', $errors['message'] ?? []),
                    'value'  => $this->e($message->otvet),
                ]
            ) ?>
        </div>
        
        <div class="flex space-x-3">
            <button type="submit" name="submit" value="submit" class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200">
                <?= __('Save') ?>
            </button>
            <a href="/guestbook/" class="bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 font-medium py-2 px-4 rounded-lg transition duration-200">
                <?= __('Back') ?>
            </a>
        </div>
    </form>
</div>

<?php $this->push('scripts') ?>
<?= $this->fetch('guestbook::ckeditor') ?>
<?php $this->stop(); ?>