<div class="col-12 col-md-8 col-lg-9 order-md-2">
    @if($pouzivatelia->isEmpty())
        <div class="alert alert-primary text-small">
            <i class="icon-info mr-2"></i>
            Zatiaľ neexistujú žiadni používatelia...
        </div>
    @else
        <div class="card card-sm shadow">
            <div class="card-header bg-secondary d-flex justify-content-end align-items-center">
                <form class="d-flex align-items-center">
                    <span class="mr-2 text-muted text-small text-nowrap">Zoradiť podľa posledného prihlásenia:</span>
                    <select class="custom-select" wire:model.change="sort">
                        <option value="1">najstaršie</option>
                        <option value="0">najnovšie</option>
                    </select>
                </form>
            </div>

            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table align-items-center mb-0">
                        <thead>
                        <tr>
                            <th scope="col">#</th>
                            <th scope="col">Používateľ</th>
                            <th scope="col">Stav</th>
                            <th scope="col" class="text-center">Posledné prihlásenie</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($pouzivatelia as $pouzivatel)
                            <tr class="bg-white">
                                <td>{{ ($pouzivatelia->currentPage() * $pouzivatelia->perPage()) - $pouzivatelia->perPage() + $loop->index + 1 }}</td>
                                <th scope="row">
                                    <a href="{{ route('portal.sprava.pouzivatelia.edit', $pouzivatel) }}">
                                        <div class="media align-items-center">
                                            <i class="icon-user text-gray fa-2x mr-2"></i>
                                            <div class="media-body">
                                                <span class="h6 font-weight-bolder mb-0">{{ $pouzivatel->cele_meno }}</span>
                                                <div class="text-uppercase text-small text-muted">{{ $pouzivatel->pracovisko->nazov }}
                                                    , kód {{ $pouzivatel->pracovisko->kod }}</div>
                                            </div>
                                        </div>
                                    </a>
                                </th>
                                <td class="text-left">
                                            <span class="badge @if($pouzivatel->jeBlokovany()) badge-warning @else badge-success @endif">
                                                {{ ucfirst($pouzivatel->stav->getLabel()) }}
                                            </span>
                                </td>
                                <td class="text-center">
                                            <span @isset($pouzivatel->datum_posledneho_prihlasenia) data-toggle="tooltip"
                                                  title="{{ $pouzivatel->datum_posledneho_prihlasenia->format('d.m.Y H:i:s') }}" @endisset>
                                                {{ isset($pouzivatel->datum_posledneho_prihlasenia) ? $pouzivatel->datum_posledneho_prihlasenia->longRelativeDiffForHumans() : '-' }}
                                            </span>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="card-footer bg-secondary d-flex justify-content-between align-items-center">
                {{ $pouzivatelia->onEachSide(5)->links('partials.pagination.pagination-links') }}
                {{ $pouzivatelia->links('partials.pagination.pagination-summary') }}
            </div>
        </div>
    @endif
</div>