{% extends 'base.html' %}
{% block content %}
  <h2>New Farm</h2>
  <div class="card">
    <form method="post" class="form">
      {{ form.hidden_tag() }}
      <div class="field">
        <label class="label">Name</label>
        {{ form.name() }}
      </div>
      <div class="field">
        <label class="label">Contact</label>
        {{ form.contact() }}
      </div>
      <div class="field">
        <label class="label">Address</label>
        {{ form.address() }}
      </div>
      <div class="field">
        <label class="label">{{ form.opening_balance.label }}</label>
        {{ form.opening_balance(step='0.01', placeholder='0.00') }}
        {% if form.opening_balance.errors %}
          <div class="error">{{ form.opening_balance.errors[0] }}</div>
        {% endif %}
      </div>
      <div class="field">
        <label class="label">{{ form.opening_balance_type.label }}</label>
        <div style="display: flex; gap: 20px; margin-top: 8px;">
          {% for choice in form.opening_balance_type %}
            <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
              {{ choice() }}
              <span>{{ choice.label.text }}</span>
            </label>
          {% endfor %}
        </div>
        {% if form.opening_balance_type.errors %}
          <div class="error">{{ form.opening_balance_type.errors[0] }}</div>
        {% endif %}
        <small style="color: #666;">Credit = You owe to farm, Debit = Farm owes you</small>
      </div>
      <div>
        {{ form.submit(class_='btn-primary') }}
      </div>
    </form>
  </div>
{% endblock %}


