<section>
    <header>
        <h2 class="text-lg font-medium text-gray-900">
            {{ __('Login History') }}
        </h2>

        <p class="mt-1 text-sm text-gray-600">
            {{ __('View your recent login activity. Review this list to ensure no unauthorized access.') }}
        </p>
    </header>

    <div class="mt-6">
        @if($loginHistory->count() > 0)
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date & Time</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP Address</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Device / Browser</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        @foreach($loginHistory as $login)
                            <tr class="hover:bg-gray-50">
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                    {{ $login->logged_in_at->format('M j, Y g:i A') }}
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-mono text-gray-600">
                                    {{ $login->ip_address }}
                                </td>
                                <td class="px-6 py-4 text-sm text-gray-600">
                                    <div class="max-w-xs truncate" title="{{ $login->user_agent }}">
                                        {{ $login->user_agent ? Str::limit($login->user_agent, 60) : 'Unknown' }}
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>

            @if($loginHistory->count() > 10)
                <div class="mt-4 text-center">
                    <p class="text-sm text-gray-500">Showing {{ count($loginHistory) }} most recent logins</p>
                </div>
            @endif
        @else
            <p class="text-gray-500 text-sm">{{ __('No login history available.') }}</p>
        @endif
    </div>
</section>
