@extends('layouts.admin')

@section('title', 'Edit Kategori')
@section('page-title', 'Edit Kategori')

@section('content')
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card border-0 shadow-sm">
                <div class="card-body p-4">
                    <form action="{{ route('admin.kategori.update', $kategori->id) }}" method="POST">
                        @csrf
                        @method('PUT')

                        <div class="mb-3">
                            <label class="form-label fw-bold">Nama Kategori <span class="text-danger">*</span></label>
                            <input type="text" name="nama_kategori"
                                class="form-control @error('nama_kategori') is-invalid @enderror"
                                value="{{ old('nama_kategori', $kategori->nama_kategori) }}" required>
                            @error('nama_kategori')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-4">
                            <label class="form-label fw-bold">Kode Ikon</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="{{ $kategori->ikon ?? 'bi bi-emoji-smile' }}"></i>
                                </span>
                                <input type="text" name="ikon" class="form-control" placeholder="Contoh: fas fa-carrot"
                                    value="{{ old('ikon', $kategori->ikon) }}">
                            </div>
                        </div>

                        <div class="d-flex justify-content-end gap-2">
                            <a href="{{ route('admin.kategori.index') }}" class="btn btn-light border px-4">Batal</a>
                            <button type="submit" class="btn btn-success px-4">Update Kategori</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection