@extends('admin.layout')

@section('title', 'Users')

@section('content')
<div class="data-table">
  <table>
    <thead>
      <tr>
        <th>Name</th>
        <th>Username</th>
        <th>Email</th>
        <th>Plan</th>
        <th>Admin</th>
        <th>Joined</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      @forelse ($users as $user)
        <tr>
          <td>{{ $user->name }}</td>
          <td>{{ $user->username }}</td>
          <td>{{ $user->email }}</td>
          <td><span class="badge badge-info">{{ ucfirst($user->plan_type) }}</span></td>
          <td>
            @if($user->is_admin)
              <span class="badge badge-warning">Yes</span>
            @else
              <span class="badge badge-success">No</span>
            @endif
          </td>
          <td>{{ $user->created_at->format('M d, Y') }}</td>
          <td>
            <form method="POST" action="{{ route('admin.users.update', $user) }}">
              @csrf
              @method('PUT')
              <select name="plan_type" class="btn btn-sm" style="background: #334155; color: #f8fafc; margin-right: 4px;">
                <option value="basic" {{ $user->plan_type === 'basic' ? 'selected' : '' }}>Basic</option>
                <option value="standard" {{ $user->plan_type === 'standard' ? 'selected' : '' }}>Standard</option>
                <option value="premium" {{ $user->plan_type === 'premium' ? 'selected' : '' }}>Premium</option>
                <option value="vip" {{ $user->plan_type === 'vip' ? 'selected' : '' }}>VIP</option>
              </select>
              <button type="submit" class="btn btn-primary btn-sm">Save</button>
            </form>
          </td>
        </tr>
      @empty
        <tr>
          <td colspan="7" class="empty-state">No users found.</td>
        </tr>
      @endforelse
    </tbody>
  </table>
</div>

<div style="margin-top: 24px;">
  {{ $users->links() }}
</div>
@endsection
