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

<div class="page-head">
  <div>
    <h1>[if {row.id}]{row.title}[else]{lang key="shop.manufacturer.new"}[/if]</h1>
    <p class="muted"><a href="/admin/shop/manufacturers">{lang key="shop.manufacturer.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>
    </div>
    <div class="form-group">
      <label>Slug</label>
      <input type="text" name="slug" value="{row.slug}" placeholder="bosch">
      <small class="help">{lang key="shop.manufacturer.slug_help"}</small>
    </div>
  </div>

  <div class="form-group">
    <label>{lang key="shop.manufacturer.logo"}</label>
    <div class="media-field">
      <div class="media-preview" id="manuf-logo-preview">[if {row.logo}]<img src="{row.logo|thumb}" alt="">[else]{lang key="shop.manufacturer.no_logo"}[/if]</div>
      <input type="hidden" name="logo" id="manuf-logo" value="{row.logo}">
      <button type="button" class="media-pick-btn" data-media-picker="#manuf-logo" data-media-preview="#manuf-logo-preview">{icon name="image" size="14"} {lang key="shop.manufacturer.choose"}</button>
      [if {row.logo}]<button type="button" class="btn btn-secondary" onclick="document.getElementById('manuf-logo').value='';document.getElementById('manuf-logo-preview').innerHTML='нет'">{lang key="shop.manufacturer.remove"}</button>[/if]
    </div>
  </div>

  <div class="form-row">
    <div class="form-group">
      <label>{lang key="shop.manufacturer.country"}</label>
      <input type="text" name="country" value="{row.country}" placeholder="{lang key="shop.manufacturer.country_placeholder"}">
    </div>
    <div class="form-group">
      <label>{lang key="shop.manufacturer.website"}</label>
      <input type="url" name="website" value="{row.website}" placeholder="https://...">
    </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>{lang key="shop.manufacturer.sort_order"}</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/manufacturers" class="btn btn-secondary">{lang key="admin.cancel"}</a>
  </div>
</form>

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