<form method="POST" action="{{ $action }}">
    @csrf
    @if($method === 'PUT') @method('PUT') @endif

    <div class="form-row">
        <div class="form-group">
            <label class="form-label">Kategori <span class="required">*</span></label>
            <select name="interview_category_id" required class="form-control form-select">
                <option value="">-- Kategori Seçin --</option>
                @foreach($categories as $cat)
                    <option value="{{ $cat->id }}" {{ (isset($simulationQuestion) && $simulationQuestion->interview_category_id == $cat->id) || (isset($selectedCategoryId) && $selectedCategoryId == $cat->id) ? 'selected' : '' }}>
                        {{ $cat->name }}
                    </option>
                @endforeach
            </select>
            @error('interview_category_id') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
        </div>

        <div class="form-group">
            <label class="form-label">Sıra <span class="required">*</span></label>
            <input type="number" name="order" required min="0" class="form-control"
                   value="{{ isset($simulationQuestion) ? $simulationQuestion->order : '1' }}">
            <div class="form-hint">Sorular bu sıraya göre gösterilir (1, 2, 3...)</div>
            @error('order') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
        </div>
    </div>

    <div class="form-group">
        <label class="form-label">Soru Metni <span class="required">*</span></label>
        <textarea name="question" required class="form-control" rows="3">{{ isset($simulationQuestion) ? $simulationQuestion->question : '' }}</textarea>
        @error('question') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
    </div>

    <div class="form-group">
        <label class="form-label">Beklenen Anahtar Kelimeler</label>
        <input type="text" name="expected_keywords" class="form-control"
               placeholder="örn: vatan, liderlik, disiplin, sorumluluk, fedakarlık"
               value="{{ isset($keywordsText) ? $keywordsText : '' }}">
        <div class="form-hint">Virgülle ayırın. Cevap değerlendirme bu kelimelerin eşleşmesine göre yapılır.</div>
        @error('expected_keywords') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
    </div>

    <div class="form-group">
        <label class="form-label">Örnek Cevap</label>
        <textarea name="sample_answer" class="form-control" rows="4"
                  placeholder="Bu soruya verilmesi beklenen ideal cevabı yazın...">{{ isset($simulationQuestion) ? $simulationQuestion->sample_answer : '' }}</textarea>
        <div class="form-hint">Kullanıcıya simülasyon sonucunda gösterilecek örnek cevap.</div>
        @error('sample_answer') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
    </div>

    <div class="form-group">
        <label class="form-label">Puan <span class="required">*</span></label>
        <input type="number" name="points" required min="1" max="100" class="form-control" style="max-width:120px;"
               value="{{ isset($simulationQuestion) ? $simulationQuestion->points : '20' }}">
        <div class="form-hint">Bu sorudan alınabilecek maksimum puan (1–100)</div>
        @error('points') <div class="form-hint" style="color:#ef4444;">{{ $message }}</div> @enderror
    </div>

    <div class="divider"></div>

    <div style="display: flex; gap: 10px;">
        <button type="submit" class="btn btn-primary">
            <svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
            Kaydet
        </button>
        <a href="{{ route('admin.simulation-questions.index') }}" class="btn btn-secondary">İptal</a>
    </div>
</form>
