<form method="post" class="admin-form">
  <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><input type="hidden" name="action" value="product">
  {% if product %}<input type="hidden" name="product_id" value="{{ product.id }}">{% endif %}
  <div class="admin-columns">
    <label>SKU<input name="sku" maxlength="50" value="{{ product.sku if product else '' }}" required></label>
    <label>Nombre<input name="name" maxlength="120" value="{{ product.name if product else '' }}" required></label>
    <label>Tipo<select name="product_type">{% for key, label in [('resource','Recurso'),('ship','Nave'),('technology','Tecnología'),('moon','Luna')] %}<option value="{{ key }}" {% if product and product.product_type == key %}selected{% endif %}>{{ label }}</option>{% endfor %}</select></label>
    <label>Clave de contenido<input name="item_key" value="{{ product.item_key if product else 'metal' }}" list="store-items"></label>
    <label>Cantidad entregada por unidad<input name="amount" type="number" min="1" value="{{ product.amount if product else 1 }}"></label>
    <label>Precio en céntimos<input name="price_cents" type="number" min="1" value="{{ product.price_cents if product else 99 }}"></label>
    <label>Moneda ISO<input name="currency" maxlength="3" value="{{ product.currency if product else payment.currency }}"></label>
    <label>Límite por cuenta, cero sin límite<input name="per_account_limit" type="number" min="0" value="{{ product.per_account_limit if product else 0 }}"></label>
    <label>Máximo de unidades por pedido<input name="per_order_limit" type="number" min="1" value="{{ product.per_order_limit if product else 10 }}"></label>
    <label>Orden<input name="sort_order" type="number" min="0" value="{{ product.sort_order if product else 100 }}"></label>
  </div>
  <datalist id="store-items">{% for key in ['metal','crystal','deuterium','food','credits'] %}<option value="{{ key }}">{% endfor %}{% for key in strategic_resource_keys %}<option value="{{ key }}">{% endfor %}{% for key in SHIPS %}<option value="{{ key }}">{% endfor %}{% for key in TECHNOLOGIES %}<option value="{{ key }}">{% endfor %}</datalist>
  <label>Descripción<textarea name="description" maxlength="500">{{ product.description if product else '' }}</textarea></label>
  <label class="check-label"><input type="checkbox" name="active" value="1" {% if not product or product.active %}checked{% endif %}> Producto activo</label>
  <button class="button button-primary" type="submit">{{ "Guardar producto" if product else "Crear producto" }}</button>
</form>
