@model IEnumerable<watcher_monitoring.Models.User>

@{
    ViewData["Title"] = "Benutzerverwaltung";
}

<div class="container-fluid px-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="section-title mb-0">Benutzerverwaltung</h1>
        <a asp-action="Create" class="btn btn-primary">
            Neuer Benutzer
        </a>
    </div>

    <div class="card">
        <div class="table-responsive">
            <table class="table table-hover" style="color: var(--text-primary); margin-bottom: 0;">
                <thead style="border-bottom: 1px solid var(--border-color);">
                    <tr>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">Benutzername</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">E-Mail</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">Status</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">API-Keys</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">Erstellt am</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">Letzter Login</th>
                        <th style="color: var(--text-secondary); font-weight: 600; padding: 1rem;">Aktionen</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var user in Model)
                    {
                        <tr style="border-bottom: 1px solid var(--border-color);">
                            <td style="padding: 1rem;">
                                <strong style="color: var(--text-primary);">@user.Username</strong>
                            </td>
                            <td style="padding: 1rem; color: var(--text-secondary);">@user.Email</td>
                            <td style="padding: 1rem;">
                                @if (user.IsActive)
                                {
                                    <span class="status-badge status-online">Aktiv</span>
                                }
                                else
                                {
                                    <span class="status-badge status-offline">Inaktiv</span>
                                }
                            </td>
                            <td style="padding: 1rem;">
                                <span class="status-badge" style="background-color: rgba(88, 166, 255, 0.15); color: var(--info); border: 1px solid var(--info);">@user.ApiKeys.Count</span>
                            </td>
                            <td style="padding: 1rem; color: var(--text-secondary);">@user.CreatedAt.ToString("dd.MM.yyyy HH:mm")</td>
                            <td style="padding: 1rem; color: var(--text-secondary);">@user.LastLogin.ToString("dd.MM.yyyy HH:mm")</td>
                            <td style="padding: 1rem;">
                                <a asp-action="Details" asp-route-id="@user.Id" class="btn btn-sm" style="background-color: var(--info); color: #fff; margin-right: 0.5rem;">Details</a>
                                <a asp-action="Edit" asp-route-id="@user.Id" class="btn btn-sm" style="background-color: var(--warning); color: #fff;">Bearbeiten</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
