{{define "content"}}
<div class="panel">
  <form class="form" method="post" enctype="multipart/form-data"
        action="{{if .New}}/admin/urun/yeni{{else}}/admin/urun/{{.P.ID}}{{end}}">

    <div class="form-row">
      <label class="grow">Ürün Adı *<input type="text" name="name" value="{{.P.Name}}" required></label>
      <label>Kategori
        <select name="category">
          {{$sel := .P.Category}}
          {{range .Categories}}<option value="{{.Slug}}" {{if eq .Slug $sel}}selected{{end}}>{{.Name}}</option>{{end}}
        </select>
      </label>
    </div>

    <div class="form-row">
      <label>Marka<input type="text" name="brand" value="{{.P.Brand}}" placeholder="Dolu, BM Toys, Aliş..." list="brandlist">
        <datalist id="brandlist"><option value="Dolu"><option value="BM Toys"><option value="Aliş"><option value="Sırbala"></datalist>
      </label>
      <label>Voltaj
        <select name="voltage">
          {{$v := .P.Voltage}}
          <option value="" {{if eq $v ""}}selected{{end}}>— Seçiniz —</option>
          <option value="6V" {{if eq $v "6V"}}selected{{end}}>6V</option>
          <option value="12V" {{if eq $v "12V"}}selected{{end}}>12V</option>
          <option value="24V" {{if eq $v "24V"}}selected{{end}}>24V</option>
        </select>
      </label>
    </div>

    <div class="form-row">
      <label>Fiyat (₺) *<input type="number" name="price" value="{{if .P.Price}}{{.P.Price}}{{end}}" required min="0"></label>
      <label>Eski Fiyat (₺, indirim göstermek için)<input type="number" name="old_price" value="{{if .P.OldPrice}}{{.P.OldPrice}}{{end}}" min="0"></label>
    </div>

    <label>Kısa Açıklama (kartlarda görünür)<input type="text" name="short" value="{{.P.Short}}"></label>
    <label>Detaylı Açıklama<textarea name="desc" rows="6">{{.P.Desc}}</textarea></label>
    <label>Özellikler (her satıra bir özellik)<textarea name="features" rows="5">{{range .P.Features}}{{.}}
{{end}}</textarea></label>

    <h3 class="form-section">Teknik Özellikler</h3>
    <div class="form-row">
      <label>Batarya<input type="text" name="battery" value="{{.P.Battery}}" placeholder="12V 7Ah"></label>
      <label>Motor<input type="text" name="motor" value="{{.P.Motor}}" placeholder="2 x 35W"></label>
      <label>Hız<input type="text" name="speed" value="{{.P.Speed}}" placeholder="3-6 km/s"></label>
    </div>
    <div class="form-row">
      <label>Taşıma Kapasitesi<input type="text" name="max_load" value="{{.P.MaxLoad}}" placeholder="35 kg"></label>
      <label>Yaş Aralığı<input type="text" name="age" value="{{.P.Age}}" placeholder="3-7 yaş"></label>
    </div>

    <div class="form-checks">
      <label class="check"><input type="checkbox" name="remote" value="1" {{if .P.Remote}}checked{{end}}> Uzaktan kumandalı</label>
      <label class="check"><input type="checkbox" name="in_stock" value="1" {{if .P.InStock}}checked{{end}}> Stokta var</label>
      <label class="check"><input type="checkbox" name="featured" value="1" {{if .P.Featured}}checked{{end}}> Öne çıkan (anasayfada göster)</label>
    </div>

    <h3 class="form-section">Görsel</h3>
    {{if .P.Image}}<img class="form-img-preview" src="{{.P.Image}}" alt="">{{end}}
    <label>Yeni Görsel Yükle (jpg, png, webp, svg)<input type="file" name="image" accept=".jpg,.jpeg,.png,.webp,.svg,.gif"></label>
    {{if and .P.Image (ne .P.Image "/static/img/placeholder.svg")}}
    <label class="check"><input type="checkbox" name="remove_image" value="1"> Mevcut görseli kaldır (yer tutucuya dön)</label>
    {{end}}

    <div class="form-foot">
      <button class="btn btn-gold" type="submit">{{if .New}}Ürünü Ekle{{else}}Kaydet{{end}}</button>
      <a class="btn btn-ghost-dark" href="/admin/urunler">Vazgeç</a>
    </div>
  </form>
</div>
{{end}}
