@extends('layouts.admin')

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

@section('admin-content')
    <div class="page-header">
        <div>
            <h3 class="page-title">Edit Unit</h3>
            <p class="text-muted mb-0">Update unit details</p>
        </div>
        <a href="{{ route('admin.units.index') }}" class="btn btn-light border shadow-sm">
            <i class="bi bi-arrow-left me-1"></i> Back to List
        </a>
    </div>

    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card shadow-sm">
                <div class="card-body p-4">
                    <form action="{{ route('admin.units.update', $unit->id) }}" method="POST">
                        @csrf
                        @method('PUT')
                        <div class="mb-3">
                            <label class="form-label fw-bold">Unit Name</label>
                            <input type="text" name="name" class="form-control" value="{{ $unit->name }}" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-bold">Unit Code</label>
                            <input type="text" name="code" class="form-control" value="{{ $unit->code }}" required>
                        </div>
                        <div class="mb-3 form-check">
                            <input type="checkbox" class="form-check-input" id="is_active" name="is_active" value="1" {{ $unit->is_active ? 'checked' : '' }}>
                            <label class="form-check-label" for="is_active">Active</label>
                        </div>

                        <button type="submit" class="btn btn-primary-gradient w-100 py-2">
                            <i class="bi bi-check-lg me-2"></i> Update Unit
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
