@extends('layouts.app') @section('content')
{{-- Page Header --}}

Support Center

Contact management or report an issue directly.

{{-- Admin/Employee Cards List --}}
@foreach($admins as $admin) {{-- ✅ AUTO ROUTE LOGIC: Admin hai to admin link, employee hai to employee link --}} @php $route = auth()->user()->role === 'admin' ? 'admin.messages.chat' : 'employee.messages.chat'; @endphp
{{ strtoupper(substr($admin->name, 0, 1)) }}

{{ $admin->name }}

{{ $admin->role === 'admin' ? 'Official Support' : 'Team Member' }}

{{-- Unread Count Badge --}} @if(isset($admin->unread_count) && $admin->unread_count > 0) {{ $admin->unread_count }} @endif
@endforeach
{{-- ✅ CHAT INTERFACE --}} @if(isset($adminToChat))
{{-- Chat Header --}}

Chatting with {{ $adminToChat->name }}

ACTIVE CONNECTION
{{-- Messages Window --}}
@forelse($messages as $msg)

{{ $msg->message }}

{{ \Carbon\Carbon::parse($msg->created_at)->diffForHumans() }}
@empty
No messages yet. Start the conversation!
@endforelse
{{-- Send Message Form --}} {{-- ✅ DYNAMIC SEND ROUTE --}} @php $sendRoute = auth()->user()->role === 'admin' ? route('admin.messages.send') : route('employee.messages.send'); @endphp
@csrf
{{-- Auto-scroll script --}} @endif
@endsection