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

<div class="page-head">
  <div>
    <h1>[if {row.id}]{row.title}[else]Новый город[/if]</h1>
    <p class="muted"><a href="/admin/cities">← К списку городов</a></p>
  </div>
</div>

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

  <div class="form-row">
    <div class="form-group">
      <label>Название *</label>
      <input type="text" name="title" value="{row.title}" required placeholder="Одесса">
    </div>
    <div class="form-group">
      <label>Slug</label>
      <input type="text" name="slug" value="{row.slug}" placeholder="odessa">
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>Страна</label>
      <input type="text" name="country" value="{row.country}" placeholder="Украина">
    </div>
    <div class="form-group">
      <label>Регион / область</label>
      <input type="text" name="region" value="{row.region}">
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>Часовой пояс</label>
      <input type="text" name="timezone" value="{row.timezone}" placeholder="Europe/Kyiv">
    </div>
    <div class="form-group">
      <label>Телефон</label>
      <input type="text" name="phone" value="{row.phone}" placeholder="+380 48 ...">
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>Широта</label>
      <input type="text" name="latitude" value="{row.latitude}" placeholder="46.482526">
    </div>
    <div class="form-group">
      <label>Долгота</label>
      <input type="text" name="longitude" value="{row.longitude}" placeholder="30.723309">
    </div>
    <div class="form-group">
      <label>Сорт.</label>
      <input type="number" name="sort_order" value="{row.sort_order}">
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label class="checkbox">
        <input type="checkbox" name="is_default" value="1" [if {row.is_default}]checked[/if]>
        Город по умолчанию (только один)
      </label>
    </div>
    <div class="form-group">
      <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/cities" class="btn btn-secondary">{lang key="admin.cancel"}</a>
  </div>
</form>

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