<?php $featureText=implode("\n",json_features($item['features_json']));?><form method="post" action="actions.php" enctype="multipart/form-data"><?= csrf_field() ?><input type="hidden" name="action" value="save_plan"><input type="hidden" name="return_page" value="plans"><input type="hidden" name="id" value="<?= e($item['id']) ?>"><div class="form-grid"><div class="form-group"><label>Nome</label><input class="input" name="name" value="<?= e($item['name']) ?>" required></div><div class="form-group"><label>Preço</label><input class="input" name="price" value="<?= e($item['price']) ?>" required></div><div class="form-group"><label>Duração em dias</label><input class="input" type="number" name="duration_days" value="<?= e($item['duration_days']) ?>"></div><div class="form-group"><label>Status</label><select name="status"><option value="active"<?= selected($item['status'],'active') ?>>Ativo</option><option value="inactive"<?= selected($item['status'],'inactive') ?>>Inativo</option></select></div><div class="form-group full"><label>Imagem do plano</label><div class="image-upload-row"><div class="image-preview image-preview-wide plan-image-preview" data-image-preview><?php if(!empty($item['image'])):?><img src="<?= e(media_url($item['image'])) ?>" alt="Imagem atual do plano"><?php else:?><span>💎</span><?php endif;?></div><div class="file-upload-copy"><label class="file-picker">Escolher imagem<input type="file" name="image_file" accept="image/jpeg,image/png,image/webp" data-image-input></label><small>A imagem fica dentro de uma área fixa e nunca cobre nome, preço, recursos ou botões.</small><?php if(!empty($item['image'])):?><label class="check-line"><input type="checkbox" name="remove_image" value="1"> Remover imagem atual ao salvar</label><?php endif;?></div></div></div><div class="form-group full"><label>Recursos — um por linha</label><textarea name="features"><?= e($featureText) ?></textarea></div></div><div class="form-actions"><button class="btn btn-primary" type="submit">Salvar plano</button></div></form>
