@extends('layout.app')

@section('content')

<div class="pagetitle">
    <h1>Normalisasi Matriks Perbandingan</h1>
    <nav>
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ route('admindash') }}">Home</a></li>
            <li class="breadcrumb-item"><a href="{{ route('perbandingan') }}">Perbandingan Kriteria</a></li>
            <li class="breadcrumb-item active">Normalisasi Kriteria</li>
        </ol>
    </nav>
</div>

<section class="section">
    <div class="row">
        <div class="col-lg-12">

            <!-- Matriks Normalisasi -->
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title mb-4">Normalisasi Matriks</h5>
                    <div class="table-responsive">
                        <table class="table table-bordered text-center">
                            <thead>
                                <tr>
                                    <th>Kriteria</th>
                                    @foreach ($kriterias as $k)
                                        <th>{{ $k->nama }}</th>
                                    @endforeach
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($kriterias as $i => $baris)
                                    <tr>
                                        <th>{{ $baris->nama }}</th>
                                        @foreach ($kriterias as $j => $kolom)
                                            <td>{{ number_format($normalisasi[$i][$j], 4) }}</td>
                                        @endforeach
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Bobot Kriteria -->
            <div class="card mt-4">
                <div class="card-body">
                    <h5 class="card-title">Bobot Kriteria</h5>
                    <div class="table-responsive">
                        <table class="table table-bordered text-center">
                            <thead>
                                <tr>
                                    <th>Kriteria</th>
                                    <th>Bobot</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($kriterias as $index => $kriteria)
                                    <tr>
                                        <td>{{ $kriteria->nama }}</td>
                                        <td>{{ number_format($bobot[$index], 4) }}</td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Tombol Proses Otomatis -->
            <div class="text-end mt-4">
                <a href="{{ route('rekomendasi.hitung.otomatis') }}" class="btn btn-success btn-lg">
                    <i class="bi bi-lightning-fill me-1"></i> Proses Rekomendasi Otomatis
                </a>
            </div>

        </div>
    </div>
</section>

@endsection
