@extends('layouts.app')

@section('title', 'Tambah Informasi Publik - Admin PPID')

@section('content')
<div class="container">
    <div class="row mb-4">
        <div class="col-md-12">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h3 class="mb-1"><i class="bi bi-plus-circle-fill me-2"></i>Tambah Informasi Publik</h3>
                    <p class="text-muted mb-0">Tambahkan informasi publik baru</p>
                </div>
                <a href="{{ route('admin.ppid.informasi.index') }}" class="btn btn-secondary">
                    <i class="bi bi-arrow-left me-1"></i> Kembali
                </a>
            </div>
        </div>
    </div>

    <div class="card card-gov shadow-sm">
        <div class="card-header">
            <h5 class="mb-0"><i class="bi bi-file-earmark-text me-2"></i>Form Informasi Publik</h5>
        </div>
        <div class="card-body">
            <form action="{{ route('admin.ppid.informasi.store') }}" method="POST">
                @csrf

                <div class="row">
                    <div class="col-md-8">
                        <div class="mb-3">
                            <label for="judul" class="form-label">Judul Informasi <span class="text-danger">*</span></label>
                            <input type="text"
                                   class="form-control @error('judul') is-invalid @enderror"
                                   id="judul"
                                   name="judul"
                                   value="{{ old('judul') }}"
                                   required>
                            @error('judul')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="ringkasan" class="form-label">Ringkasan <span class="text-danger">*</span></label>
                            <textarea class="form-control @error('ringkasan') is-invalid @enderror"
                                      id="ringkasan"
                                      name="ringkasan"
                                      rows="3"
                                      required>{{ old('ringkasan') }}</textarea>
                            @error('ringkasan')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="isi" class="form-label">Isi Lengkap</label>
                            <textarea class="form-control @error('isi') is-invalid @enderror"
                                      id="isi"
                                      name="isi"
                                      rows="6">{{ old('isi') }}</textarea>
                            @error('isi')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                            <small class="text-muted">Opsional - Isi detail informasi</small>
                        </div>
                    </div>

                    <div class="col-md-4">
                        <div class="mb-3">
                            <label for="kategori_id" class="form-label">Kategori <span class="text-danger">*</span></label>
                            <select class="form-select @error('kategori_id') is-invalid @enderror"
                                    id="kategori_id"
                                    name="kategori_id"
                                    required>
                                <option value="">Pilih Kategori</option>
                                @foreach($kategoris as $kategori)
                                    <option value="{{ $kategori->id }}"
                                            {{ old('kategori_id') == $kategori->id ? 'selected' : '' }}>
                                        {{ $kategori->nama }}
                                    </option>
                                @endforeach
                            </select>
                            @error('kategori_id')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="tahun" class="form-label">Tahun <span class="text-danger">*</span></label>
                            <input type="number"
                                   class="form-control @error('tahun') is-invalid @enderror"
                                   id="tahun"
                                   name="tahun"
                                   min="2000"
                                   max="{{ date('Y') + 1 }}"
                                   value="{{ old('tahun', date('Y')) }}"
                                   required>
                            @error('tahun')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <label for="file_name" class="form-label">Nama File</label>
                            <input type="text"
                                   class="form-control @error('file_name') is-invalid @enderror"
                                   id="file_name"
                                   name="file_name"
                                   value="{{ old('file_name') }}"
                                   placeholder="contoh: laporan-2024.pdf">
                            @error('file_name')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                            <small class="text-muted">Opsional - Nama file dokumen</small>
                        </div>

                        <div class="mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input"
                                       type="checkbox"
                                       id="is_published"
                                       name="is_published"
                                       {{ old('is_published', true) ? 'checked' : '' }}>
                                <label class="form-check-label" for="is_published">
                                    Publikasikan
                                </label>
                            </div>
                            <small class="text-muted">Centang untuk menampilkan di halaman publik</small>
                        </div>
                    </div>
                </div>

                <hr class="my-4">

                <div class="d-flex justify-content-between">
                    <a href="{{ route('admin.ppid.informasi.index') }}" class="btn btn-secondary">
                        <i class="bi bi-x-circle me-1"></i> Batal
                    </a>
                    <button type="submit" class="btn btn-gov-primary">
                        <i class="bi bi-save me-1"></i> Simpan Informasi
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
