{% extends "base.html" %}
{% block body %}
<div class="mb-6 flex items-center justify-between">
  <div>
    <h1 class="text-3xl font-bold">{{ title }}</h1>
  </div>
  <a class="btn btn-outline" href="/sources">Назад</a>
</div>

<div class="card bg-base-100 shadow-sm border border-base-200 max-w-3xl">
  <div class="card-body">
    <form method="post" action="{{ action }}" class="flex flex-col gap-4">
      <input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
      
      <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
        <div class="form-control">
          <label class="label"><span class="label-text font-bold">Площадка</span></label>
          <select name="platform" class="select select-bordered w-full">
            <option value="vk" {% if not source or source.platform == "vk" %}selected{% endif %}>VK</option>
          </select>
        </div>
        
        <div class="form-control">
          <label class="label"><span class="label-text font-bold">Приоритет</span></label>
          <input name="priority" type="number" value="{{ source.priority if source else 100 }}" class="input input-bordered w-full">
        </div>
        
        <div class="form-control md:col-span-2">
          <label class="label"><span class="label-text font-bold">Название</span></label>
          <input name="name" value="{{ source.name if source else '' }}" required class="input input-bordered w-full">
        </div>
        
        <div class="form-control">
          <label class="label"><span class="label-text font-bold">Тэг</span></label>
          <input name="tag" value="{{ source.tag if source else '' }}" placeholder="academy_gear" class="input input-bordered w-full">
        </div>
        
        <div class="form-control md:col-span-2">
          <label class="label"><span class="label-text font-bold">Ссылка</span></label>
          <input name="url" value="{{ source.url if source else '' }}" required class="input input-bordered w-full text-primary">
        </div>
      </div>
      
      <div class="form-control mt-4">
        <label class="label cursor-pointer justify-start gap-3">
          <input name="active" type="checkbox" class="toggle toggle-primary" {% if not source or source.active %}checked{% endif %}>
          <span class="label-text font-bold">Активен (парсер будет собирать посты)</span>
        </label>
      </div>
      
      <div class="card-actions justify-end mt-4 pt-4 border-t border-base-200">
        <button class="btn btn-primary" type="submit">Сохранить</button>
      </div>
    </form>
  </div>
</div>
{% endblock %}
