@extends('admin.layouts.app')
@section('title', 'Kullanıcı Düzenle')
@section('page-title', 'Kullanıcı Düzenle')

@section('content')

<div class="mb-4">
    <a href="{{ route('admin.users.show', $user) }}" class="btn btn-secondary btn-sm">
        <i class="bi bi-arrow-left"></i> Geri Dön
    </a>
</div>

<div class="row justify-content-center">
<div class="col-xl-5 col-lg-6">
    <div class="card">
        <div class="card-header">
            <div class="user-avatar sm">{{ strtoupper(substr($user->name,0,1)) }}</div>
            <h6>{{ $user->name }}</h6>
            <span style="font-size:12px;color:var(--text2)">— Düzenle</span>
        </div>
        <div class="card-body">
            <form method="POST" action="{{ route('admin.users.update', $user) }}">
                @csrf @method('PUT')

                <div class="mb-3">
                    <label class="form-label">Ad Soyad <span style="color:var(--danger)">*</span></label>
                    <input type="text" name="name" class="form-control"
                           value="{{ old('name',$user->name) }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">E-posta <span style="color:var(--danger)">*</span></label>
                    <input type="email" name="email" class="form-control"
                           value="{{ old('email',$user->email) }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">Rol</label>
                    <select name="role" class="form-select">
                        <option value="user"      {{ $user->role==='user'      ?'selected':'' }}>Kullanıcı</option>
                        <option value="moderator" {{ $user->role==='moderator' ?'selected':'' }}>Moderatör</option>
                        <option value="admin"     {{ $user->role==='admin'     ?'selected':'' }}>Admin</option>
                    </select>
                </div>

                <div class="mb-3">
                    <label class="form-label">
                        Yeni Şifre
                        <span style="color:var(--text2);font-size:11px">(boş bırakırsan değişmez)</span>
                    </label>
                    <input type="password" name="password" class="form-control" autocomplete="new-password">
                </div>

                <div class="mb-4">
                    <label class="form-label">
                        Admin Rozeti
                        <span style="color:var(--text2);font-size:11px">(yorumlarda altın etiket)</span>
                    </label>
                    <input type="text" name="admin_badge" class="form-control" maxlength="32"
                           value="{{ old('admin_badge',$user->admin_badge) }}"
                           placeholder="Örn: Beta Tester, VIP, Staff...">
                    <div class="form-text">Boş bırakırsan rozet gösterilmez.</div>
                </div>

                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary flex-grow-1">
                        <i class="bi bi-floppy"></i> Kaydet
                    </button>
                    <a href="{{ route('admin.users.show',$user) }}" class="btn btn-secondary">İptal</a>
                </div>
            </form>
        </div>
    </div>
</div>
</div>

@endsection
