@extends('layouts.admin')
@section('title', 'Chat')
@section('content')
    <div class="card" style="height: 75vh;">
        <div class="row g-0 h-100">
            <div class="col-md-4 border-end h-100 overflow-auto">
                <div class="p-3 bg-light border-bottom">
                    <h6 class="mb-0">Daftar Percakapan</h6>
                </div>
                <div class="list-group list-group-flush">
                    @forelse($chatList as $chat)
                        <a href="{{ route('petani.pesan.show', $chat['lawan_id']) }}"
                            class="list-group-item list-group-item-action py-3">
                            <div class="d-flex w-100 justify-content-between">
                                <h6 class="mb-1 text-primary">{{ $chat['nama'] }}</h6>
                                <small class="text-muted" style="font-size: 11px">{{ $chat['time'] }}</small>
                            </div>
                            <p class="mb-1 text-truncate small text-secondary">{{ $chat['last_message'] }}</p>
                            @if ($chat['unread'] > 0)
                                <span class="badge bg-danger rounded-pill">{{ $chat['unread'] }}</span>
                            @endif
                        </a>
                    @empty
                        <div class="p-4 text-center text-muted">Belum ada pesan.</div>
                    @endforelse
                </div>
            </div>

            <div class="col-md-8 h-100 d-flex align-items-center justify-content-center bg-white">
                <div class="text-center text-muted">
                    <i class="bi bi-chat-dots display-1"></i>
                    <p class="mt-3">Pilih kontak di sebelah kiri untuk mulai chatting.</p>
                </div>
            </div>
        </div>
    </div>
@endsection
