
<div>
    <div style="display: flex; justify-content: end; align-items: center; gap: 10px; margin-bottom: 10px;">
        Düzenlenen diller:
        @foreach($languages as $language)
            <a href="#" wire:click.prevent="changeLanguage('{{ $language->short }}')" wire:key="lang-{{ $language->id }}" class="btn btn-sm {{ $selectedLanguage == $language->short ? 'btn-primary' : 'btn-outline-primary' }}">
                {{ strtoupper($language->short) }}
            </a>
        @endforeach
    </div>

    <form>
        <div class="row mb-3">
            <label class="col-sm-2 col-form-label" for="title">Başlık @if($type != 2)*@endif</label>
            <div class="col-sm-10">
                <input class="form-control" id="title" type="text" wire:model.live="title" @if($type != 2) required @endif autocomplete="off">
                <div>
                    @error('title') <span class="error">{{ $message }}</span> @enderror
                </div>
            </div>
        </div>

        @if($type === 1)
            <div class="row mb-3">
                <label class="col-sm-2 col-form-label" for="url">URL *</label>
                <div class="col-sm-10">
                    <input class="form-control" id="url" type="text" wire:model.live="url" autocomplete="off">
                    <div>
                        @error('url') <span class="error">{{ $message }}</span> @enderror
                    </div>
                </div>
            </div>
        @endif

        @if($type === 2)
            <div class="row mb-3">
                <label class="col-sm-2 col-form-label" for="page">Sayfa *</label>
                <div class="col-sm-10">
                    <select class="form-control" id="page" wire:model.live="page_id">
                        <option value="">Sayfa seçin...</option>
                        @foreach($this->pages as $page)
                            <option value="{{ $page->id }}">{{ $page->title }}</option>
                            @if($page->children->count() > 0)
                                @include('partials.sub-pages', ['children' => $page->children, 'prefix' => '--'])
                            @endif
                        @endforeach
                    </select>
                    <div>
                        @error('page') <span class="error">{{ $message }}</span> @enderror
                    </div>
                </div>
            </div>
        @endif

        <div class="row mb-3">
            <label class="col-sm-2 col-form-label" for="description">Açıklama</label>
            <div class="col-sm-10">
                <textarea class="form-control" id="description" wire:model.live="description" autocomplete="off"></textarea>
                <div>
                    @error('description') <span class="error">{{ $message }}</span> @enderror
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <label class="col-sm-2 col-form-label" for="target">Hedef</label>
            <div class="col-sm-10">
                <select class="form-control" id="target" wire:model.live="target">
                    <option value="_self">Aynı Sekme</option>
                    <option value="_blank">Yeni Sekme</option>
                </select>
                <div>
                    @error('target') <span class="error">{{ $message }}</span> @enderror
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label class="col-sm-2 col-form-label" for="class">Sınıf</label>
            <div class="col-sm-10">
                <input class="form-control" id="class" type="text" wire:model="class" autocomplete="off">
                <div>
                    @error('class') <span class="error">{{ $message }}</span> @enderror
                </div>
            </div>
        </div>

        <button class="btn btn-primary" type="submit" wire:click.prevent="saveAndRedirect" wire:loading.attr="disabled" wire:target="save, saveAndRedirect">Kaydet</button>
        <button class="btn btn-primary" type="submit" wire:click.prevent="save" wire:loading.attr="disabled" wire:target="save, saveAndRedirect">Kaydet ve Eklemeye Devam Et</button>

    </form>
</div>
