@extends('layouts.admin')

@section('title', 'Edit Operator')
@section('page-title', 'Edit Operator')

@section('content')
<div class="row justify-content-center">
    <div class="col-lg-7 col-xl-6">
        <div class="d-flex align-items-center gap-3 mb-4">
            <a href="{{ route('admin.operators.index') }}" class="btn btn-sm px-3 py-2" style="background:#f0f2f5; border-radius:10px;">
                <i class="bi bi-arrow-left"></i>
            </a>
            <div>
                <h5 class="fw-bold mb-0">Edit Operator</h5>
                <p class="text-muted small mb-0">Update: {{ $operator->name }}</p>
            </div>
        </div>

        <div class="premium-card p-4 p-lg-5">
            @if($errors->any())
                <div class="alert border-0 mb-4" style="background:rgba(239,68,68,.08); color:#dc2626; border-radius:12px;">
                    <ul class="mb-0 small">
                        @foreach($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            <form method="POST" action="{{ route('admin.operators.update', $operator) }}">
                @csrf
                @method('PUT')
                <div class="mb-3">
                    <label for="name" class="form-label small fw-semibold text-muted text-uppercase" style="letter-spacing:.5px;">Full Name <span class="text-danger">*</span></label>
                    <input type="text" class="form-control py-2 @error('name') is-invalid @enderror" style="border-radius:10px;"
                           id="name" name="name" value="{{ old('name', $operator->name) }}" required>
                </div>
                <div class="mb-3">
                    <label for="email" class="form-label small fw-semibold text-muted text-uppercase" style="letter-spacing:.5px;">Email Address <span class="text-danger">*</span></label>
                    <input type="email" class="form-control py-2 @error('email') is-invalid @enderror" style="border-radius:10px;"
                           id="email" name="email" value="{{ old('email', $operator->email) }}" required>
                </div>
                <div class="mb-4">
                    <label for="phone" class="form-label small fw-semibold text-muted text-uppercase" style="letter-spacing:.5px;">Phone Number</label>
                    <input type="text" class="form-control py-2 @error('phone') is-invalid @enderror" style="border-radius:10px;"
                           id="phone" name="phone" value="{{ old('phone', $operator->phone) }}">
                </div>

                <hr class="my-4" style="border-color:#e5e7eb;">

                <div class="mb-3">
                    <label for="password" class="form-label small fw-semibold text-muted text-uppercase" style="letter-spacing:.5px;">New Password</label>
                    <input type="password" class="form-control py-2 @error('password') is-invalid @enderror" style="border-radius:10px;"
                           id="password" name="password" placeholder="Leave blank to keep current">
                </div>
                <div class="mb-4">
                    <label for="password_confirmation" class="form-label small fw-semibold text-muted text-uppercase" style="letter-spacing:.5px;">Confirm New Password</label>
                    <input type="password" class="form-control py-2" style="border-radius:10px;"
                           id="password_confirmation" name="password_confirmation" placeholder="Re-enter new password">
                </div>

                <div class="d-flex gap-3">
                    <button type="submit" class="btn px-4 py-2" style="background:linear-gradient(135deg, #780045, #F54927); color:#fff; font-weight:600; border-radius:12px;">
                        <i class="bi bi-check-lg me-1"></i>Update Operator
                    </button>
                    <a href="{{ route('admin.operators.index') }}" class="btn px-4 py-2" style="background:#f0f2f5; color:#6b7280; font-weight:600; border-radius:12px;">
                        Cancel
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
