@extends('layouts.app')

@section('title', 'Kelola Opsi Jawaban - SKM Survey')

@section('content')
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-12">
            <h2 style="color: #1e3a8a; font-weight: 700;">
                <i class="bi bi-list-check me-2"></i> Kelola Opsi Jawaban
            </h2>
            <p class="text-muted">Konfigurasi opsi jawaban untuk Survey Kepuasan Masyarakat</p>
        </div>
    </div>

    <div class="card card-gov shadow-sm mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">
                <i class="bi bi-list-ul me-2"></i> Daftar Opsi Jawaban
            </h5>
            <a href="{{ route('admin.answer-options.create') }}" class="btn btn-gov-primary">
                <i class="bi bi-plus-circle me-2"></i> Tambah Opsi Jawaban
            </a>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead class="table-light">
                        <tr>
                            <th style="width: 50px;">No</th>
                            <th>Text Jawaban</th>
                            <th style="width: 100px;" class="text-center">Score</th>
                            <th style="width: 100px;" class="text-center">Weight</th>
                            <th style="width: 100px;" class="text-center">Order</th>
                            <th style="width: 100px;" class="text-center">Status</th>
                            <th style="width: 200px;" class="text-center">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($answerOptions as $index => $option)
                            <tr>
                                <td class="fw-semibold">{{ $index + 1 }}</td>
                                <td>
                                    <strong>{{ $option->text }}</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">Tidak Aktif</span>
                                    @endif
                                </td>
                                <td>
                                    <div class="btn-group" role="group">
                                        <a href="{{ route('admin.answer-options.edit', $option->id) }}" class="btn btn-sm btn-primary">
                                            <i class="bi bi-pencil"></i> Edit
                                        </a>
                                        <form action="{{ route('admin.answer-options.destroy', $option->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Apakah Anda yakin ingin menghapus opsi jawaban ini?');">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn btn-sm btn-danger">
                                                <i class="bi bi-trash"></i> Hapus
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="7" class="text-center py-4">
                                    <i class="bi bi-inbox text-muted" style="font-size: 3rem;"></i>
                                    <p class="text-muted mt-2 mb-0">Belum ada opsi jawaban</p>
                                    <a href="{{ route('admin.answer-options.create') }}" class="btn btn-gov-primary mt-3">
                                        <i class="bi bi-plus-circle me-2"></i> Tambah Opsi Jawaban Pertama
                                    </a>
                                </td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection



