@php
    $registro = $registro ?? null;
    $val = static fn ($field, $default = '') => old($field, $registro->{$field} ?? $default);
@endphp

<div class="row g-3">
    <div class="col-md-8">
        <label class="form-label">{{ __('Título do Mapa') }} <span class="text-danger">*</span></label>
        <input type="text" name="titulo" class="form-control @error('titulo') is-invalid @enderror" value="{{ $val('titulo') }}" maxlength="255" required>
        @error('titulo')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>

    <div class="col-md-4">
        <label class="form-label">{{ __('Tema de Mapa') }}</label>
        <select name="mapa_tema_id" class="form-select">
            <option value="">{{ __('Selecione...') }}</option>
            @foreach($temas as $tema)
                <option value="{{ $tema->id }}" @selected((string) $val('mapa_tema_id') === (string) $tema->id)>{{ $tema->nome }}</option>
            @endforeach
        </select>
    </div>

    <div class="col-md-9">
        <label class="form-label">{{ __('Link (URL do mapa) ') }}<span class="text-danger">*</span></label>
        <input type="url" name="link" class="form-control @error('link') is-invalid @enderror" value="{{ $val('link') }}" maxlength="1000" placeholder="{{ __('https://...') }}" required>
        @error('link')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>

    <div class="col-md-3">
        <label class="form-label">{{ __('Status') }}</label>
        <select name="status" class="form-select">
            <option value="ATIVADO" @selected($val('status', 'ATIVADO') === 'ATIVADO')>{{ __('Ativado') }}</option>
            <option value="DESATIVADO" @selected($val('status') === 'DESATIVADO')>{{ __('Desativado') }}</option>
        </select>
    </div>
</div>

<div class="mt-4">
    <button type="submit" class="btn btn-success"><i class="fa-solid fa-floppy-disk"></i> {{ __('Salvar') }}</button>
</div>
