<div class="space-y-5">
    <x-panel :title="__('sessions.title')" :subtitle="__('sessions.subtitle')">
        <div class="space-y-4">
            <div class="divide-y divide-line">
                @forelse ($sessions as $session)
                    <div class="flex items-center gap-3 py-3">
                        <span @class([
                            'grid h-9 w-9 shrink-0 place-items-center rounded-md border',
                            'border-accent/30 bg-accent/10 text-accent-text' => $session['isCurrent'],
                            'border-line bg-inset text-ink-3' => ! $session['isCurrent'],
                        ])>
                            <x-icon name="logout" class="h-4 w-4" />
                        </span>
                        <div class="min-w-0 flex-1">
                            <div class="flex items-center gap-2">
                                <p class="truncate text-sm text-ink">{{ $session['userAgentShort'] }}</p>
                                @if ($session['isCurrent'])
                                    <x-badge tone="accent">{{ __('sessions.this_device') }}</x-badge>
                                @endif
                            </div>
                            <p class="truncate font-mono text-[11px] text-ink-3">
                                {{ $session['ip'] ?? __('common.none') }}
                                · {{ __('sessions.last_active', ['time' => $session['lastActivity']->diffForHumans()]) }}
                            </p>
                        </div>
                    </div>
                @empty
                    <p class="py-3 font-mono text-[11px] text-ink-3">{{ __('sessions.none') }}</p>
                @endforelse
            </div>

            <div class="flex flex-col gap-2 border-t border-line pt-4 sm:flex-row sm:items-center sm:justify-between">
                <p class="font-mono text-[11px] text-ink-4">{{ __('sessions.hint') }}</p>
                <div class="flex flex-col gap-2 sm:flex-row sm:items-center">
                    <x-modal-trigger variant="danger-soft" class="shrink-0" action="confirmLogoutOthers">
                        <x-icon name="logout" class="h-3.5 w-3.5" /> {{ __('sessions.logout_others') }}
                    </x-modal-trigger>
                    @can('manage-users')
                        <x-modal-trigger variant="danger" class="shrink-0" action="confirmLogoutAll">
                            <x-icon name="power" class="h-3.5 w-3.5" /> {{ __('sessions.logout_all') }}
                        </x-modal-trigger>
                    @endcan
                </div>
            </div>
        </div>
    </x-panel>
</div>
