@extends('layout.app')

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

@section('content')
<div class="container-fluid">
    <div class="card bg-light-info shadow-none position-relative overflow-hidden mb-4">
        <div class="card-body px-4 py-3">
            <div class="row align-items-center">
                <div class="col-9">
                    <h4 class="fw-semibold mb-8">Edit Kategori</h4>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a class="text-muted" href="{{ route('categories.index') }}">Daftar Kategori</a></li>
                            <li class="breadcrumb-item" aria-current="page">Perbarui Data</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white py-3">
                    <h5 class="card-title mb-0 fw-semibold">Ubah Detail Kategori</h5>
                </div>
                <div class="card-body">
                    <form action="{{ route('categories.update', $category->id) }}" method="POST">
                        @csrf
                        @method('PUT')

                        <div class="mb-4">
                            <label class="form-label fw-semibold">Nama Kategori</label>
                            <input type="text" 
                                   name="name" 
                                   class="form-control @error('name') is-invalid @enderror" 
                                   placeholder="Masukkan nama kategori baru" 
                                   value="{{ old('name', $category->name) }}" 
                                   required 
                                   autofocus>
                            
                            @error('name')
                                <div class="invalid-feedback">
                                    {{ $message }}
                                </div>
                            @enderror
                            <div class="form-text text-muted">
                                Nama kategori akan diperbarui di seluruh database.
                            </div>
                        </div>

                        <div class="d-flex align-items-center gap-2">
                            <button type="submit" class="btn btn-primary px-4">
                                <i class="ti ti-device-floppy me-1 fs-4"></i> Simpan Perubahan
                            </button>
                            <a href="{{ route('categories.index') }}" class="btn btn-light text-danger px-4">
                                Batal
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-md-6 d-none d-md-block">
            <div class="card border-0 shadow-none bg-transparent">
                <div class="card-body text-center mt-4">
                    <i class="ti ti-edit fs-10 text-primary opacity-25"></i>
                    <p class="text-muted mt-3">Mengubah nama kategori akan otomatis memperbarui pengelompokan produk terkait.</p>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
