@extends('layouts.admin')

@section('page_title', 'Edit Department: ' . $department->name)

@section('content')
    <div class="row mb-4">
        <div class="col-lg-8 mx-auto">
            <div class="d-flex align-items-center gap-3 mb-4">
                <a href="{{ route('admin.departments.index') }}"
                    class="btn btn-light rounded-circle p-2 d-flex align-items-center justify-content-center border"
                    style="width: 40px; height: 40px;">
                    <span class="material-symbols-outlined fs-5 text-secondary">arrow_back</span>
                </a>
                <div>
                    <h3 class="fw-extrabold tracking-tight mb-0" style="font-weight: 800; font-size: 1.5rem;">Edit Department
                    </h3>
                    <p class="text-secondary opacity-75 mb-0" style="font-size: 0.8125rem;">Modify existing department
                        details.</p>
                </div>
            </div>

            <div class="card border-0 shadow-sm"
                style="border-radius: 1rem; border: 1px solid rgba(0,0,0,0.05) !important;">
                <div class="card-body p-5">
                    <form action="{{ route('admin.departments.update', $department->id) }}" method="POST">
                        @csrf
                        @method('PUT')

                        <div class="mb-4">
                            <label class="text-uppercase fw-bold text-secondary mb-2 d-block"
                                style="font-size: 0.65rem; letter-spacing: 0.05rem;">Department Name</label>
                            <input type="text" name="name"
                                class="form-control border-0 bg-light py-2.5 rounded-3 @error('name') is-invalid @enderror"
                                value="{{ old('name', $department->name) }}" required>
                            @error('name')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-4">
                            <label class="text-uppercase fw-bold text-secondary mb-2 d-block"
                                style="font-size: 0.65rem; letter-spacing: 0.05rem;">Description</label>
                            <textarea name="description"
                                class="form-control border-0 bg-light py-2.5 rounded-3 @error('description') is-invalid @enderror" rows="4">{{ old('description', $department->description) }}</textarea>
                            @error('description')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mt-5 pt-3 border-top d-flex gap-3">
                            <a href="{{ route('admin.departments.index') }}"
                                class="btn btn-light flex-grow-1 py-3 fw-bold border-0 bg-light text-secondary rounded-3">Cancel</a>
                            <button type="submit"
                                class="btn btn-primary flex-grow-1 py-3 fw-bold rounded-3 shadow-sm d-flex justify-content-center align-items-center gap-2">
                                <span class="material-symbols-outlined fs-5">save</span> Update Department
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

@push('styles')
    <style>
        .tracking-tight {
            letter-spacing: -0.015rem;
        }

        .form-control:focus {
            background-color: #f8fafc !important;
            box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1) !important;
        }
    </style>
@endpush
