{{--
    Partial: секция «Технические характеристики» формы автомобиля
    Переменные из родителя: $v, $engineVols, $colorsExt, $colorsInt
--}}
<div class="card card-info card-outline">
    <div class="card-header"><h3 class="card-title">Технические характеристики</h3></div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label>Тип двигателя</label>
                    <select name="engine_type" class="form-control @error('engine_type') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        @foreach(['petrol'=>'Бензин','diesel'=>'Дизель','hybrid'=>'Гибрид','electric'=>'Электро','gas'=>'Газ','other'=>'Другое'] as $val=>$lbl)
                            <option value="{{ $val }}" @selected($v('engine_type') === $val)>{{ $lbl }}</option>
                        @endforeach
                    </select>
                    @error('engine_type')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>Объём (л)</label>
                    <select name="engine_volume" class="form-control @error('engine_volume') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        @foreach($engineVols as $ev)
                            <option value="{{ $ev->value }}" @selected((string)$v('engine_volume') === $ev->value)>{{ $ev->value }}</option>
                        @endforeach
                    </select>
                    @error('engine_volume')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>Мощность (л.с.)</label>
                    <input type="number" name="engine_power_hp"
                           class="form-control @error('engine_power_hp') is-invalid @enderror"
                           value="{{ $v('engine_power_hp') }}" min="0" max="5000">
                    @error('engine_power_hp')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>Коробка передач</label>
                    <select name="transmission" class="form-control @error('transmission') is-invalid @enderror">
                        <option value="">— не указана —</option>
                        @foreach(['manual'=>'Механика','automatic'=>'Автомат','robot'=>'Робот','variator'=>'Вариатор','electric'=>'Электро'] as $val=>$lbl)
                            <option value="{{ $val }}" @selected($v('transmission') === $val)>{{ $lbl }}</option>
                        @endforeach
                    </select>
                    @error('transmission')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label>Привод</label>
                    <select name="drive" class="form-control @error('drive') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        @foreach(['FWD'=>'Передний','RWD'=>'Задний','AWD'=>'Полный (AWD)','4WD'=>'Полный (4WD)'] as $val=>$lbl)
                            <option value="{{ $val }}" @selected($v('drive') === $val)>{{ $lbl }}</option>
                        @endforeach
                    </select>
                    @error('drive')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>Пробег (км)</label>
                    <input type="number" name="mileage_km"
                           class="form-control @error('mileage_km') is-invalid @enderror"
                           value="{{ $v('mileage_km') }}" min="0">
                    @error('mileage_km')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                    <label>Руль</label>
                    <select name="steering" class="form-control @error('steering') is-invalid @enderror">
                        <option value="left"  @selected($v('steering','left') === 'left')>Левый</option>
                        <option value="right" @selected($v('steering') === 'right')>Правый</option>
                    </select>
                    @error('steering')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                    <label>Дверей</label>
                    <input type="number" name="doors"
                           class="form-control @error('doors') is-invalid @enderror"
                           value="{{ $v('doors') }}" min="1" max="10">
                    @error('doors')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                    <label>Владельцев</label>
                    <input type="number" name="owners_count"
                           class="form-control @error('owners_count') is-invalid @enderror"
                           value="{{ $v('owners_count') }}" min="0">
                    @error('owners_count')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-4">
                <div class="form-group">
                    <label>Цвет кузова</label>
                    <select name="color_exterior" class="form-control @error('color_exterior') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        @foreach($colorsExt as $c)
                            <option value="{{ $c->value }}" @selected($v('color_exterior') === $c->value)>{{ $c->value }}</option>
                        @endforeach
                    </select>
                    @error('color_exterior')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label>Цвет салона</label>
                    <select name="color_interior" class="form-control @error('color_interior') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        @foreach($colorsInt as $c)
                            <option value="{{ $c->value }}" @selected($v('color_interior') === $c->value)>{{ $c->value }}</option>
                        @endforeach
                    </select>
                    @error('color_interior')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label>ПТС</label>
                    <select name="pts" class="form-control @error('pts') is-invalid @enderror">
                        <option value="">— не указан —</option>
                        <option value="original"    @selected($v('pts') === 'original')>Оригинал</option>
                        <option value="duplicate"   @selected($v('pts') === 'duplicate')>Дубликат</option>
                        <option value="electronic"  @selected($v('pts') === 'electronic')>Электронный</option>
                    </select>
                    @error('pts')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label>VIN</label>
                    <input type="text" name="vin"
                           class="form-control @error('vin') is-invalid @enderror"
                           value="{{ $v('vin') }}" maxlength="17" placeholder="17 символов">
                    @error('vin')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>Гос. номер</label>
                    <input type="text" name="plate"
                           class="form-control @error('plate') is-invalid @enderror"
                           value="{{ $v('plate') }}" maxlength="20">
                    @error('plate')<div class="invalid-feedback">{{ $message }}</div>@enderror
                </div>
            </div>
            <div class="col-md-3 d-flex align-items-end">
                <div class="form-group w-100">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="customs_cleared"
                               name="customs_cleared" value="1"
                               @checked($v('customs_cleared', true))>
                        <label class="custom-control-label" for="customs_cleared">Растаможен</label>
                    </div>
                    <div class="custom-control custom-checkbox mt-1">
                        <input type="checkbox" class="custom-control-input" id="accident_free"
                               name="accident_free" value="1"
                               @checked($v('accident_free', false))>
                        <label class="custom-control-label" for="accident_free">Без ДТП</label>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
