@extends('admin.layouts.app')

@section('content')

<style>
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
*, *::before, *::after { box-sizing: border-box; }
body, * { font-family: 'Plus Jakarta Sans', sans-serif; }

.edit-wrap {
    padding: 2rem 2.5rem 3rem;
    max-width: 680px;
    margin: 0 auto;
}

.edit-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}
.edit-title { font-size: 22px; font-weight: 700; color: #0D215C; }
.edit-sub   { font-size: 13px; color: #94a3b8; margin-top: 4px; }

.btn-back {
    padding: 8px 18px;
    border-radius: 10px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all .2s;
}
.btn-back:hover { background: #dbeafe; color: #1d4ed8; }

.edit-card {
    background: #fff;
    border: 1px solid #edf1f7;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(13,33,92,.05);
}
.edit-card-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 10px;
}
.edit-card-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #0D215C;
    margin: 0;
}

.edit-body { padding: 1.5rem; }

.info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
}
.info-row:last-of-type { border-bottom: none; }
.info-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.info-value {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.form-group { margin-top: 1.5rem; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
    cursor: pointer;
    color: #0f172a;
    transition: border .2s;
    appearance: auto;
}
.form-select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

.status-info {
    margin-top: 10px;
    padding: 10px 14px;
    background: #fffbeb;
    border-radius: 10px;
    font-size: 12px;
    color: #92400e;
    border: 1px solid #fde68a;
}

.btn-submit {
    width: 100%;
    padding: 14px;
    margin-top: 1.5rem;
    background: #0D215C;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
    box-shadow: 0 4px 14px rgba(13,33,92,.2);
}
.btn-submit:hover { background: #1e3a8a; transform: translateY(-1px); }

.pill {
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 50px;
}
.pill-ok  { background: #dcfce7; color: #15803d; }
.pill-run { background: #dbeafe; color: #1d4ed8; }
.pill-rev { background: #fef9c3; color: #92400e; }
.pill-del { background: #fee2e2; color: #b91c1c; }
</style>

<div class="edit-wrap">

    {{-- HEADER --}}
    <div class="edit-header">
        <div>
            <div class="edit-title">Ubah Status Kegiatan</div>
            <div class="edit-sub">Perbarui status kemajuan kegiatan lapangan</div>
        </div>
        <a href="{{ route('admin.kegiatan.show', $activity->id) }}" class="btn-back">← Kembali</a>
    </div>

    {{-- FORM CARD --}}
    <div class="edit-card">
        <div class="edit-card-header">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0D215C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>
            <h3>Form Edit Status</h3>
        </div>

        <div class="edit-body">
            {{-- ALERT --}}
            @if($errors->any())
            <div style="background:#fee2e2;color:#b91c1c;padding:12px 16px;border-radius:10px;margin-bottom:1rem;font-size:13px;">
                @foreach($errors->all() as $e) <div>• {{ $e }}</div> @endforeach
            </div>
            @endif

            {{-- INFO KEGIATAN --}}
            <div class="info-row">
                <div class="info-label">Nomor Surat</div>
                <div class="info-value">{{ $activity->nomor_surat ?? '-' }}</div>
            </div>
            <div class="info-row">
                <div class="info-label">Nama Kegiatan</div>
                <div class="info-value">{{ $activity->nama_kegiatan }}</div>
            </div>
            <div class="info-row">
                <div class="info-label">Status Saat Ini</div>
                <div class="info-value">
                    @php
                        $pillMap = [
                            'selesai'        => ['pill-ok',  'Selesai'],
                            'on_progres'     => ['pill-run', 'Sedang Berjalan'],
                            'telah_ditinjau' => ['pill-rev', 'Telah Ditinjau'],
                            'dibatalkan'     => ['pill-del', 'Dibatalkan'],
                        ];
                        $pc = $pillMap[$activity->status] ?? ['pill-run', ucfirst($activity->status)];
                    @endphp
                    <span class="pill {{ $pc[0] }}">{{ $pc[1] }}</span>
                </div>
            </div>

            {{-- FORM --}}
            <form action="{{ route('admin.kegiatan.update', $activity->id) }}" method="POST">
                @csrf
                @method('POST')

                <div class="form-group">
                    <label class="form-label" for="status">Status Baru</label>
                    <select name="status" id="status" class="form-select">
                        <option value="on_progres"    {{ $activity->status == 'on_progres'    ? 'selected' : '' }}>Sedang Berjalan</option>
                        <option value="selesai"       {{ $activity->status == 'selesai'       ? 'selected' : '' }}>Selesai</option>
                        <option value="telah_ditinjau" {{ $activity->status == 'telah_ditinjau' ? 'selected' : '' }}>Telah Ditinjau</option>
                    </select>
                    <div class="status-info">
                        ⚠️ Perubahan status bersifat permanen dan akan tercatat dalam riwayat sistem.
                    </div>
                </div>

                <button type="submit" class="btn-submit">Simpan Perubahan Status</button>
            </form>
        </div>
    </div>

</div>

@endsection
