<?php $pageTitle = Lang::get('edit_collection') . ' - ' . Lang::get('app_name'); ?>
<?php require APP_ROOT . '/views/layouts/header.php'; ?>

<div class="max-w-3xl mx-auto">
    <div class="flex items-center justify-between mb-6">
        <h1 class="text-2xl font-bold"><?= Lang::get('edit_collection') ?></h1>
        <a href="<?= APP_URL ?>/collections/<?= $collection['id'] ?>" class="text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 text-sm transition-colors">
            &larr; <?= Lang::get('back') ?>
        </a>
    </div>

    <form method="POST" action="<?= APP_URL ?>/collections/<?= $collection['id'] ?>">
        <input type="hidden" name="csrf_token" value="<?= Session::getCsrfToken() ?>">

        <div class="bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6 mb-6">
            <div class="mb-4">
                <label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"><?= Lang::get('collection_name') ?> *</label>
                <input type="text" id="name" name="name" value="<?= htmlspecialchars($collection['name']) ?>" required
                       class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary-500 focus:border-primary-500 outline-none transition-colors">
            </div>

            <div class="mb-4">
                <label for="description" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"><?= Lang::get('collection_desc') ?></label>
                <textarea id="description" name="description" rows="3"
                          class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary-500 focus:border-primary-500 outline-none transition-colors resize-y"><?= htmlspecialchars($collection['description'] ?? '') ?></textarea>
            </div>
        </div>

        <div class="flex space-x-3">
            <button type="submit" class="btn-gradient btn-gradient-blue btn-gradient-icon">
                <?= Lang::get('save') ?>
            </button>
            <a href="<?= APP_URL ?>/collections/<?= $collection['id'] ?>" class="btn-gradient btn-gradient-gray">
                <?= Lang::get('cancel') ?>
            </a>
        </div>
    </form>
</div>

<?php require APP_ROOT . '/views/layouts/footer.php'; ?>
