<x-app-layout>
    @section('page-title', $pageTitle)
    <div class="d-flex align-items-center mb-4">
        <a href="{{ route('admin.pengumuman.index') }}" class="btn btn-outline-secondary me-3">
            <i class="bi bi-arrow-left"></i>
        </a>
        <h3 class="my-0 fw-bold">Formulir Edit Pengumuman</h3>
    </div>

    <div class="row justify-content-center">
        <div class="col-md-10">
            <div class="card border-0 shadow-sm">
                <div class="card-body p-4">
                    <div class="card-body">
                        <form action="{{ route('admin.pengumuman.update', $pengumuman->id) }}" method="POST">
                            @csrf
                            @method('PUT')
                            <div class="mb-3">
                                <label for="title" class="form-label">Judul Pengumuman <span class="text-danger">*</span></label>
                                <input type="text" name="title" class="form-control @error('title') is-invalid @enderror" id="title"
                                    value="{{ old('title', $pengumuman->title) }}" maxlength="50">
                                @error('title')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="type" class="form-label">Tipe Pengumuman <span class="text-danger">*</span></label>
                                <select name="type" class="form-select @error('type') is-invalid @enderror" id="type">
                                    <option value="" disabled>Pilih tipe...</option>
                                    <option value="info" @if (old('type', $pengumuman->type) == 'info') selected @endif>Info</option>
                                    <option value="success" @if (old('type', $pengumuman->type) == 'success') selected @endif>Success</option>
                                    <option value="warning" @if (old('type', $pengumuman->type) == 'warning') selected @endif>Warning</option>
                                    <option value="danger" @if (old('type', $pengumuman->type) == 'danger') selected @endif>Danger</option>
                                </select>
                                @error('type')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="content" class="form-label">Isi Pengumuman <span class="text-danger">*</span></label>
                                <textarea name="content" class="form-control @error('content') is-invalid @enderror" id="content" rows="5" maxlength="255">{{ old('content', $pengumuman->content) }}</textarea>
                                @error('content')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                            <hr>
                            <div class="d-flex justify-content-end">
                                <button type="submit" class="btn btn-primary px-4 fw-bold">Simpan Perubahan</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    @push('scripts')
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Script removed to allow standard server-side validation
        });
    </script>
    @endpush
</x-app-layout>