<?php

/** @var yii\web\View $this */
/** @var common\models\FoodLibrary $model */

use yii\bootstrap5\ActiveForm;
use yii\bootstrap5\Html;
use yii\helpers\Url;
?>

<?php $f = ActiveForm::begin(['id' => 'food-form']) ?>

<div class="row g-3">
    <div class="col-md-6">
        <?= $f->field($model, 'name')->textInput(['placeholder' => 'e.g. Brown Rice']) ?>
    </div>
    <div class="col-md-3">
        <?= $f->field($model, 'category')->dropDownList([
            '' => '— Category —',
            'Grains' => 'Grains', 'Protein' => 'Protein',
            'Dairy' => 'Dairy', 'Vegetable' => 'Vegetable',
            'Fruit' => 'Fruit', 'Fat' => 'Fat',
            'Beverage' => 'Beverage', 'Other' => 'Other',
        ]) ?>
    </div>
    <div class="col-md-3">
        <?= $f->field($model, 'serving_size')->textInput(['placeholder' => '100g']) ?>
    </div>

    <div class="col-md-2">
        <?= $f->field($model, 'calories')->input('number', ['step' => '0.1', 'min' => '0']) ?>
    </div>
    <div class="col-md-2">
        <?= $f->field($model, 'protein')->input('number', ['step' => '0.1', 'min' => '0']) ?>
    </div>
    <div class="col-md-2">
        <?= $f->field($model, 'carbs')->input('number', ['step' => '0.1', 'min' => '0']) ?>
    </div>
    <div class="col-md-2">
        <?= $f->field($model, 'fats')->input('number', ['step' => '0.1', 'min' => '0']) ?>
    </div>
    <div class="col-md-2">
        <?= $f->field($model, 'fiber')->input('number', ['step' => '0.1', 'min' => '0']) ?>
    </div>
    <div class="col-md-6">
        <?= $f->field($model, 'tags')->textInput(['placeholder' => 'high-protein, low-fat, vegan…']) ?>
    </div>
    <div class="col-md-2 d-flex align-items-end pb-2">
        <?= $f->field($model, 'is_active')->checkbox(['label' => 'Active']) ?>
    </div>
</div>

<div class="d-flex gap-2 mt-2">
    <?= Html::submitButton('<i class="bi bi-check-lg"></i> Save', ['class' => 'btn btn-primary']) ?>
    <?= Html::a('Cancel', Url::to(['/food-library/index']), ['class' => 'btn btn-outline-secondary']) ?>
</div>

<?php ActiveForm::end() ?>
