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

<div class="page-head">
  <div>
    <h1>Города <span class="muted" style="font-weight:400">· {total}</span></h1>
    <p class="muted">Справочник для региональной доставки, контактов и многогородовой версии сайта.</p>
  </div>
  <div class="actions">
    <a class="btn btn-primary" href="/admin/cities/create">+ Новый город</a>
  </div>
</div>

<form method="get" action="/admin/cities" class="prod-filters">
  <div class="prod-filter-row" style="grid-template-columns: 1fr auto">
    <div class="prod-search">
      {icon name="search" size="16"}
      <input type="search" name="q" value="{q}" placeholder="Поиск города…">
    </div>
    <button type="submit" class="btn btn-primary">Применить</button>
  </div>
</form>

[if {cities}]
<div class="prod-table-wrap">
<table class="table prod-table">
  <thead>
    <tr>
      <th>Название</th>
      <th>Страна</th>
      <th>Регион</th>
      <th>Часовой пояс</th>
      <th>Телефон</th>
      <th>По умолч.</th>
      <th>Активен</th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    [foreach var="cities" as="c"]
      <tr>
        <td><a href="/admin/cities/{c.id}/edit" class="prod-title">{c.title}</a><div class="prod-cell-sub"><code class="prod-slug">{c.slug}</code></div></td>
        <td>[if {c.country}]{c.country}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {c.region}]{c.region}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {c.timezone}]{c.timezone}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {c.phone}]{c.phone}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {c.is_default}]{icon name="check" size="14"}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {c.is_active}]<span class="badge badge-published">да</span>[else]<span class="badge badge-draft">нет</span>[/if]</td>
        <td class="actions prod-row-actions">
          <a href="/admin/cities/{c.id}/edit" class="btn btn-ghost btn-sm">Ред.</a>
          <form method="post" action="/admin/cities/{c.id}/delete" style="display:inline" data-confirm="Удалить?" data-confirm-danger="1">
            {csrf}<button type="submit" class="row-icon-btn row-icon-danger" title="Удалить">{icon name="close" size="14"}</button>
          </form>
        </td>
      </tr>
    [/foreach]
  </tbody>
</table>
</div>
{include file="_partials/pagination.tpl"}
[else]
<div class="empty-state">
  <div class="icon">{icon name="pin" size="42"}</div>
  <p>Городов ещё нет.</p>
  <a href="/admin/cities/create" class="btn btn-primary">+ Добавить первый</a>
</div>
[/if]

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