@extends('layouts.app')

@section('title', 'Detail Pertanyaan - SKM Survey')

@section('content')
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-12">
            <a href="{{ route('admin.questions.index') }}" class="btn btn-secondary mb-3">
                <i class="bi bi-arrow-left"></i> Kembali
            </a>
            <h2 style="color: #1e3a8a; font-weight: 700;">
                <i class="bi bi-eye me-2"></i> Detail Pertanyaan
            </h2>
        </div>
    </div>

    <div class="card card-gov shadow-sm mb-4">
        <div class="card-header">
            <h5 class="mb-0">Informasi Pertanyaan</h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-3">
                    <strong>Kode:</strong>
                    <p><span class="badge-gov">{{ $question->code }}</span></p>
                </div>
                <div class="col-md-3">
                    <strong>Elemen:</strong>
                    <p>{{ $question->element }}</p>
                </div>
                <div class="col-md-3">
                    <strong>Urutan:</strong>
                    <p><span class="badge bg-primary">{{ $question->order }}</span></p>
                </div>
                <div class="col-md-3">
                    <strong>Status:</strong>
                    <p>
                        @if($question->is_active)
                            <span class="badge bg-success">Aktif</span>
                        @else
                            <span class="badge bg-secondary">Nonaktif</span>
                        @endif
                    </p>
                </div>
            </div>
            <div class="mt-3">
                <strong>Pertanyaan:</strong>
                <p class="mb-0">{{ $question->question }}</p>
            </div>
        </div>
    </div>

    <div class="card card-gov shadow-sm">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Opsi Jawaban</h5>
            <a href="{{ route('admin.questions.edit', $question->id) }}" class="btn btn-sm btn-gov-primary">
                <i class="bi bi-pencil me-1"></i> Edit
            </a>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead class="table-light">
                        <tr>
                            <th>No</th>
                            <th>Label</th>
                            <th class="text-center">Score</th>
                            <th class="text-center">Weight</th>
                            <th class="text-center">Urutan</th>
                            <th class="text-center">Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($question->answerOptions as $index => $option)
                            <tr>
                                <td>{{ $index + 1 }}</td>
                                <td><strong>{{ $option->label }}</strong></td>
                                <td class="text-center"><span class="badge bg-info">{{ $option->score }}</span></td>
                                <td class="text-center"><span class="badge bg-secondary">{{ number_format($option->weight, 2) }}</span></td>
                                <td class="text-center"><span class="badge bg-primary">{{ $option->order }}</span></td>
                                <td class="text-center">
                                    @if($option->is_active)
                                        <span class="badge bg-success">Aktif</span>
                                    @else
                                        <span class="badge bg-secondary">Nonaktif</span>
                                    @endif
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="6" class="text-center">Belum ada opsi jawaban</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection

