@extends('layouts.admin')

@section('title', 'Tambah Rule CF')

@section('content')

<div class="container">

    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white">
            <b>Form Tambah Rule CF</b>
        </div>

        <div class="card-body">

            {{-- ALERT ERROR --}}
            @if($errors->any())
                <div class="alert alert-danger">
                    <ul class="mb-0">
                        @foreach($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            {{-- ALERT LOGIKA CF --}}
            @if(session('error'))
                <div class="alert alert-warning">
                    {{ session('error') }}
                </div>
            @endif

            <form action="{{ route('rule.store') }}" method="POST">
                @csrf

                {{-- GEJALA --}}
                <div class="mb-3">
                    <label class="form-label">Gejala</label>
                    <select name="gejala_id" class="form-control">
                        <option value="">-- Pilih Gejala --</option>
                        @foreach($gejalas as $g)
                            <option value="{{ $g->id }}">
                                {{ $g->kode }} - {{ $g->nama }}
                            </option>
                        @endforeach
                    </select>
                </div>

                {{-- PENYAKIT --}}
                <div class="mb-3">
                    <label class="form-label">Penyakit</label>
                    <select name="penyakit_id" class="form-control">
                        <option value="">-- Pilih Penyakit --</option>
                        @foreach($penyakits as $p)
                            <option value="{{ $p->id }}">
                                {{ $p->kode }} - {{ $p->nama }}
                            </option>
                        @endforeach
                    </select>
                </div>

                {{-- MB --}}
                <div class="mb-3">
                    <label class="form-label">MB (Measure of Belief)</label>
                    <input type="number" step="0.01" name="mb" 
                           class="form-control"
                           placeholder="Contoh: 0.8 (nilai 0 - 1)"
                           value="{{ old('mb') }}">
                </div>

                {{-- MD --}}
                <div class="mb-3">
                    <label class="form-label">MD (Measure of Disbelief)</label>
                    <input type="number" step="0.01" name="md" 
                           class="form-control"
                           placeholder="Contoh: 0.2 (nilai 0 - 1)"
                           value="{{ old('md') }}">
                </div>

                {{-- BUTTON --}}
                <div class="d-flex justify-content-between">
                    <a href="{{ route('rule.index') }}" class="btn btn-secondary">
                        ← Kembali
                    </a>

                    <button class="btn btn-success">
                        Simpan Rule
                    </button>
                </div>

            </form>

        </div>
    </div>

</div>

@endsection