@extends('layouts.admin')

@section('title', 'Tambah Jabatan Fungsional')
@section('page_title', 'Tambah Jabatan Fungsional Baru')

@section('style')
<style>
    

    

    

    .master-panel {
        border: 1px solid rgba(0,0,0,0.05);
        border-radius: 8px;
        box-shadow: none;
        overflow: hidden;
    }

    .master-panel .card-header {
        display: flex;
        align-items: center;
        padding: 1rem 1.15rem;
        color: #4a3728;
        background: #ffffff;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        border-radius: 0;
    }

    .master-panel .card-header h5 {
        margin: 0;
        font-size: 1rem;
        font-weight: 750;
    }

    .panel-subtitle {
        margin-top: 0.2rem;
        color: #64748b;
        font-size: 0.8rem;
    }
</style>
@endsection

@section('content')
<section class="page-hero">
    <div>
        <h3><i class="fas fa-plus"></i> Tambah Jabatan Fungsional</h3>
        <p>Isi form berikut untuk menambah jabatan fungsional baru.</p>
    </div>
    <a href="{{ route('admin.jabatan.index') }}" class="btn btn-outline-secondary">
        <i class="fas fa-arrow-left"></i> Kembali
    </a>
</section>

<div class="row justify-content-center">
    <div class="col-lg-6">
        <div class="card master-panel">
            <div class="card-header">
                <div>
                    <h5>Form Tambah Jabatan</h5>
                    <div class="panel-subtitle">Semua field bertanda <span class="text-danger">*</span> wajib diisi.</div>
                </div>
            </div>
            <div class="card-body">
                <form action="{{ route('admin.jabatan.store') }}" method="POST">
                    @csrf

                    <div class="mb-3">
                        <label for="unit_kerja_id" class="form-label">Unit Kerja <span class="text-danger">*</span></label>
                        <select id="unit_kerja_id" name="unit_kerja_id"
                            class="form-select @error('unit_kerja_id') is-invalid @enderror" required>
                            <option value="">-- Pilih Unit Kerja --</option>
                            @foreach ($unitKerjaList as $unitKerja)
                                <option value="{{ $unitKerja->id }}" @selected((string) old('unit_kerja_id') === (string) $unitKerja->id)>
                                    {{ $unitKerja->nama_unit }}
                                </option>
                            @endforeach
                        </select>
                        @error('unit_kerja_id')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="mb-3">
                        <label for="nama_jabatan" class="form-label">Nama Jabatan <span class="text-danger">*</span></label>
                        <input type="text" id="nama_jabatan" name="nama_jabatan"
                            class="form-control @error('nama_jabatan') is-invalid @enderror"
                            list="nama_jabatan_list"
                            placeholder="Contoh: Analis Kebijakan"
                            value="{{ old('nama_jabatan') }}" required>
                        <datalist id="nama_jabatan_list">
                            @foreach ($namaJabatanList as $namaJabatan)
                                <option value="{{ $namaJabatan }}">
                            @endforeach
                        </datalist>
                        @error('nama_jabatan')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="mb-3">
                        <label for="jenjang_jabatan_id" class="form-label">Jenjang <span class="text-danger">*</span></label>
                        <select id="jenjang_jabatan_id" name="jenjang_jabatan_id"
                            class="form-select @error('jenjang_jabatan_id') is-invalid @enderror" required>
                            <option value="">-- Pilih Jenjang --</option>
                            @foreach ($jenjangList as $jenjang)
                                <option value="{{ $jenjang->id }}" @selected((string) old('jenjang_jabatan_id') === (string) $jenjang->id)>
                                    {{ $jenjang->nama_jenjang }}
                                </option>
                            @endforeach
                        </select>
                        @error('jenjang_jabatan_id')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="mb-4">
                        <label for="kategori" class="form-label">Kategori</label>
                        <input type="text" id="kategori" class="form-control" value="Keahlian" readonly>
                        <input type="hidden" name="kategori" value="Keahlian">
                    </div>

                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> Simpan
                        </button>
                        <a href="{{ route('admin.jabatan.index') }}" class="btn btn-outline-secondary">
                            <i class="fas fa-arrow-left"></i> Kembali
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
