@extends('admin.layouts.app')
@section('title', 'Edit User')
@section('content')
<div class="card" style="max-width:600px">
    <div class="card-header">Edit User: {{ $user->name }}</div>
    <form action="{{ route('admin.users.update', $user) }}" method="POST">
        @csrf @method('PUT')
        <div class="form-row">
            <div class="form-group">
                <label>Name</label>
                <input type="text" name="name" class="form-control" value="{{ old('name', $user->name) }}" required>
            </div>
            <div class="form-group">
                <label>Email</label>
                <input type="email" name="email" class="form-control" value="{{ old('email', $user->email) }}" required>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Phone</label>
                <input type="text" name="phone" class="form-control" value="{{ old('phone', $user->phone) }}">
            </div>
            <div class="form-group">
                <label>Company</label>
                <input type="text" name="company" class="form-control" value="{{ old('company', $user->company) }}">
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Role</label>
                <select name="role" class="form-control">
                    <option value="customer" {{ $user->role == 'customer' ? 'selected' : '' }}>Customer</option>
                    <option value="technician" {{ $user->role == 'technician' ? 'selected' : '' }}>Technician</option>
                    <option value="admin" {{ $user->role == 'admin' ? 'selected' : '' }}>Admin</option>
                </select>
            </div>
            <div class="form-group">
                <label class="checkbox-label" style="margin-top:25px">
                    <input type="checkbox" name="is_active" value="1" {{ $user->is_active ? 'checked' : '' }}> Active
                </label>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>New Password (leave blank to keep)</label>
                <input type="password" name="password" class="form-control">
            </div>
            <div class="form-group">
                <label>Confirm Password</label>
                <input type="password" name="password_confirmation" class="form-control">
            </div>
        </div>
        <button type="submit" class="btn btn-primary">Update User</button>
    </form>
</div>
@endsection
