{include file="_partials/head.tpl"}

<div class="page-head">
  <div>
    <h1>[if {row.id}]{row.title}[else]{lang key="shop.shipping_method.new"}[/if]</h1>
    <p class="muted"><a href="/admin/shop/shipping">{lang key="shop.shipping_method.back_to_list"}</a></p>
  </div>
</div>

<form method="post" action="{form_action}" class="card">
  {csrf}

  <div class="form-row">
    <div class="form-group">
      <label>{lang key="shop.common.title"} *</label>
      <input type="text" name="title" value="{row.title}" required placeholder="{lang key="shop.shipping_method.title_placeholder"}">
    </div>
    <div class="form-group">
      <label>Slug</label>
      <input type="text" name="slug" value="{row.slug}" placeholder="courier">
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>{lang key="shop.shipping_method.mode"}</label>
      <select name="mode">
        <option value="flat"      [if {row.mode}="flat"]selected[/if]>{lang key="shop.shipping_method.mode_flat_full"}</option>
        <option value="by_weight" [if {row.mode}="by_weight"]selected[/if]>{lang key="shop.shipping_method.mode_by_weight"}</option>
        <option value="free"      [if {row.mode}="free"]selected[/if]>{lang key="shop.shipping_method.mode_free"}</option>
        <option value="pickup"    [if {row.mode}="pickup"]selected[/if]>{lang key="shop.shipping_method.mode_pickup"}</option>
      </select>
    </div>
    <div class="form-group">
      <label>{lang key="shop.shipping_method.cost"}, {currency}</label>
      <input type="number" min="0" step="0.01" name="cost" value="{row.cost}">
    </div>
    <div class="form-group">
      <label>{lang key="shop.shipping_method.free_from"}, {currency}</label>
      <input type="number" min="0" step="0.01" name="free_from" value="{row.free_from}" placeholder="{lang key="shop.shipping_method.free_from_placeholder"}">
    </div>
  </div>

  <div class="form-group">
    <label>{lang key="shop.manufacturer.description"}</label>
    <textarea name="description" rows="4">{row.description}</textarea>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>Сорт.</label>
      <input type="number" name="sort_order" value="{row.sort_order}">
    </div>
    <div class="form-group" style="display:flex;align-items:end;gap:8px">
      <label class="checkbox">
        <input type="checkbox" name="is_active" value="1" [if {row.is_active}]checked[/if]>
        Активен
      </label>
    </div>
  </div>

  <div class="form-actions">
    <button type="submit" class="btn btn-primary">{lang key="admin.save"}</button>
    <a href="/admin/shop/shipping" class="btn btn-secondary">{lang key="admin.cancel"}</a>
  </div>
</form>

{include file="_partials/foot.tpl"}
