<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Lembar Jawab IKK</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        .header-section {
            background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
            color: white;
            padding: 2rem 0;
        }
        .card {
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }
        .table th {
            background-color: #2a5298;
            color: white;
            border: none;
            font-weight: 600;
        }
        .status-badge {
            padding: 0.4rem 0.8rem;
            border-radius: 15px;
            font-size: 0.85rem;
            font-weight: 600;
        }
        .draft { background-color: #6c757d; color: white; }
        .diajukan { background-color: #0d6efd; color: white; }
        .diverifikasi { background-color: #198754; color: white; }
        .perlu-perbaikan { background-color: #dc3545; color: white; }
    </style>
</head>
<body>
    <div class="header-section">
        <div class="container">
            <div class="row align-items-center">
                <div class="col-md-8">
                    <h1 class="mb-2">
                        <i class="fas fa-clipboard-list me-3"></i>
                        Lembar Jawab IKK
                    </h1>
                    <p class="mb-0 fs-5">Sistem Pengisian Jawaban Indikator Kinerja Kunci</p>
                </div>
                <div class="col-md-4 text-end">
                    <a href="{{ route('ikk.lembar-jawab.grafik') }}" class="btn btn-info me-2">
                        <i class="fas fa-chart-bar me-2"></i>Grafik Penilaian
                    </a>
                    <a href="{{ route('ikk.lembar-jawab.create') }}" class="btn btn-success">
                        <i class="fas fa-plus me-2"></i>Isi Lembar Jawab
                    </a>
                </div>
            </div>
        </div>
    </div>

    <div class="container my-5">
        @if(session('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <i class="fas fa-check-circle me-2"></i>
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        @endif

        <!-- Filter -->
        <div class="card mb-4">
            <div class="card-body">
                <form method="GET">
                    <div class="row align-items-end">
                        <div class="col-md-4">
                            <label class="form-label fw-semibold">OPD</label>
                            <select name="opd" class="form-select">
                                <option value="">Semua OPD</option>
                                @foreach($opdList as $opdItem)
                                    <option value="{{ $opdItem }}" {{ $opd == $opdItem ? 'selected' : '' }}>{{ $opdItem }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label class="form-label fw-semibold">Tahun</label>
                            <select name="tahun" class="form-select">
                                <option value="">Semua Tahun</option>
                                @foreach($tahunList as $thn)
                                    <option value="{{ $thn }}" {{ $tahun == $thn ? 'selected' : '' }}>{{ $thn }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label class="form-label fw-semibold">Cari</label>
                            <input type="text" name="search" class="form-control" placeholder="Kode IKK...">
                        </div>
                        <div class="col-md-2">
                            <button type="submit" class="btn btn-primary w-100">
                                <i class="fas fa-search me-2"></i>Filter
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <!-- Tabel Lembar Jawab -->
        <div class="card">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead>
                            <tr>
                                <th width="5%">No</th>
                                <th width="10%">Kode IKK</th>
                                <th width="35%">IKK Output</th>
                                <th width="15%">OPD</th>
                                <th width="8%">Tahun</th>
                                <th width="10%">Capaian</th>
                                <th width="12%">Status</th>
                                <th width="15%">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($lembarJawab as $index => $jawab)
                            <tr>
                                <td class="text-center">{{ $index + 1 }}</td>
                                <td class="fw-bold text-primary">{{ $jawab->kode_ikk }}</td>
                                <td>{{ $jawab->ikk_output }}</td>
                                <td><small>{{ $jawab->opd }}</small></td>
                                <td class="text-center">{{ $jawab->tahun }}</td>
                                <td class="text-center fw-bold">{{ $jawab->capaian }}%</td>
                                <td>
                                    <span class="status-badge {{ strtolower(str_replace(' ', '-', $jawab->status)) }}">
                                        {{ $jawab->status }}
                                    </span>
                                </td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a href="{{ route('ikk.lembar-jawab.show', $jawab->id) }}" class="btn btn-outline-info" title="Lihat">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                        @if($jawab->status == 'DRAFT')
                                            <a href="{{ route('ikk.lembar-jawab.edit', $jawab->id) }}" class="btn btn-outline-warning" title="Edit">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                        @endif
                                    </div>
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <!-- Statistik -->
        <div class="row mt-4">
            <div class="col-md-3">
                <div class="card text-center">
                    <div class="card-body">
                        <i class="fas fa-clipboard-list fa-2x text-primary mb-2"></i>
                        <h4 class="fw-bold">{{ count($lembarJawab) }}</h4>
                        <p class="mb-0 text-muted">Total Lembar Jawab</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center">
                    <div class="card-body">
                        <i class="fas fa-check-circle fa-2x text-success mb-2"></i>
                        <h4 class="fw-bold">{{ collect($lembarJawab)->where('status', 'DIVERIFIKASI')->count() }}</h4>
                        <p class="mb-0 text-muted">Diverifikasi</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center">
                    <div class="card-body">
                        <i class="fas fa-clock fa-2x text-warning mb-2"></i>
                        <h4 class="fw-bold">{{ collect($lembarJawab)->where('status', 'DIAJUKAN')->count() }}</h4>
                        <p class="mb-0 text-muted">Menunggu Verifikasi</p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center">
                    <div class="card-body">
                        <i class="fas fa-edit fa-2x text-secondary mb-2"></i>
                        <h4 class="fw-bold">{{ collect($lembarJawab)->where('status', 'DRAFT')->count() }}</h4>
                        <p class="mb-0 text-muted">Draft</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>