@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; }

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

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}
.detail-title { font-size: 22px; font-weight: 700; color: #0D215C; }
.detail-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; }

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

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.detail-field {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-field:nth-child(odd) { border-right: 1px solid #f1f5f9; }
.detail-field.full {
    grid-column: 1 / -1;
    border-right: none;
}
.df-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.df-value {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.pill {
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 50px;
    letter-spacing: .3px;
}
.pill-ok  { background: #dcfce7; color: #15803d; }
.pill-run { background: #dbeafe; color: #1d4ed8; }
.pill-rev { background: #fef9c3; color: #92400e; }
.pill-del { background: #fee2e2; color: #b91c1c; }

.petugas-list {
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.petugas-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}
.petugas-ava {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0D215C, #2563eb);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-bar {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
}
.action-btn {
    padding: 10px 22px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: .2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-edit   { background: #0D215C; color: #fff; box-shadow: 0 4px 12px rgba(13,33,92,.2); }
.btn-edit:hover { background: #1e3a8a; }
.btn-batal  { background: #fee2e2; color: #b91c1c; }
.btn-batal:hover { background: #fecaca; }
</style>

<div class="detail-wrap">

    {{-- HEADER --}}
    <div class="detail-header">
        <div>
            <div class="detail-title">Detail Kegiatan</div>
            <div class="detail-sub">Informasi lengkap penugasan lapangan</div>
        </div>
        <a href="{{ route('admin.kegiatan.index') }}" class="btn-back">← Kembali</a>
    </div>

    {{-- INFO UTAMA --}}
    <div class="detail-card">
        <div class="detail-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="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"/><rect x="9" y="3" width="6" height="4" rx="1"/></svg>
            <h3>Informasi Penugasan</h3>
        </div>

        <div class="detail-grid">
            <div class="detail-field">
                <div class="df-label">Nomor Surat</div>
                <div class="df-value">{{ $activity->nomor_surat ?? '-' }}</div>
            </div>
            <div class="detail-field">
                <div class="df-label">Status</div>
                <div class="df-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>
            <div class="detail-field full">
                <div class="df-label">Nama Kegiatan</div>
                <div class="df-value">{{ $activity->nama_kegiatan }}</div>
            </div>
            <div class="detail-field">
                <div class="df-label">Tanggal Mulai</div>
                <div class="df-value">{{ \Carbon\Carbon::parse($activity->tanggal)->locale('id')->translatedFormat('d F Y') }}</div>
            </div>
            <div class="detail-field">
                <div class="df-label">Tanggal Selesai</div>
                <div class="df-value">
                    {{ $activity->tanggal_selesai ? \Carbon\Carbon::parse($activity->tanggal_selesai)->locale('id')->translatedFormat('d F Y') : '-' }}
                </div>
            </div>
            <div class="detail-field">
                <div class="df-label">Penanggung Jawab</div>
                <div class="df-value">{{ optional($activity->user)->name ?? '-' }}</div>
            </div>
            <div class="detail-field">
                <div class="df-label">Terakhir Diperbarui</div>
                <div class="df-value">{{ \Carbon\Carbon::parse($activity->updated_at)->locale('id')->translatedFormat('d F Y, H:i') }}</div>
            </div>
        </div>
    </div>

    {{-- DAFTAR PETUGAS --}}
    <div class="detail-card">
        <div class="detail-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="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
            <h3>Petugas yang Ditugaskan</h3>
        </div>
        <div class="petugas-list">
            @forelse($activity->petugas ?? [] as $p)
                @php $nm = is_array($p) ? ($p['name'] ?? '-') : ($p->name ?? '-'); @endphp
                <div class="petugas-chip">
                    <div class="petugas-ava">{{ strtoupper(substr($nm, 0, 2)) }}</div>
                    {{ $nm }}
                </div>
            @empty
                <span style="color:#94a3b8;font-size:13px;">Belum ada petugas yang ditetapkan.</span>
            @endforelse
        </div>
    </div>



</div>

@endsection
