@extends('layouts.admin')

@section('title', 'Edit Customer')

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

@section('breadcrumbs')
    <a href="{{ route('admin.customers.index') }}" class="hover:text-primary">Customers</a>
    <span class="material-symbols-outlined text-xs">chevron_right</span>
    <span class="text-primary font-medium">{{ $customer->name }}</span>
@endsection

@section('content')
<div class="max-w-4xl mx-auto">
    <form method="POST" action="{{ route('admin.customers.update', $customer) }}" class="bg-white rounded-xl shadow-sm border border-[#e5e7eb] p-6">
        @csrf
        @method('PUT')
        
        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <div class="md:col-span-2">
                <h3 class="text-lg font-bold text-[#111418] text-gray-900 mb-4">Basic Information</h3>
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Name <span class="text-red-500">*</span></label>
                <input type="text" name="name" value="{{ old('name', $customer->name) }}" required class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
                @error('name')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Email</label>
                <input type="email" name="email" value="{{ old('email', $customer->email) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
                @error('email')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">New Password (leave empty to keep current)</label>
                <input type="password" name="password" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
                @error('password')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Phone</label>
                <input type="text" name="phone" value="{{ old('phone', $customer->phone) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Company</label>
                <input type="text" name="company" value="{{ old('company', $customer->company) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div class="md:col-span-2">
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Address</label>
                <textarea name="address" rows="2" class="w-full rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">{{ old('address', $customer->address) }}</textarea>
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">City</label>
                <input type="text" name="city" value="{{ old('city', $customer->city) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">State</label>
                <input type="text" name="state" value="{{ old('state', $customer->state) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">ZIP Code</label>
                <input type="text" name="zip" value="{{ old('zip', $customer->zip) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Country</label>
                <input type="text" name="country" value="{{ old('country', $customer->country) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Tax ID</label>
                <input type="text" name="tax_id" value="{{ old('tax_id', $customer->tax_id) }}" class="w-full h-11 rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">
            </div>
            
            <div class="md:col-span-2">
                <label class="block text-sm font-medium text-[#111418] text-gray-900 mb-2">Notes</label>
                <textarea name="notes" rows="3" class="w-full rounded-lg border border-[#dbe0e6] bg-white px-3 py-2 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary text-gray-900">{{ old('notes', $customer->notes) }}</textarea>
            </div>
            
            <div>
                <label class="flex items-center gap-2">
                    <input type="checkbox" name="is_active" value="1" {{ old('is_active', $customer->is_active) ? 'checked' : '' }} class="rounded border-gray-300 text-primary focus:ring-primary">
                    <span class="text-sm font-medium text-[#111418] text-gray-900">Active</span>
                </label>
            </div>
        </div>
        
        <div class="flex justify-end gap-3 mt-6 pt-6 border-t border-[#e5e7eb]">
            <a href="{{ route('admin.customers.index') }}" class="px-6 py-2 border border-[#dbe0e6] text-[#617589] rounded-lg hover:bg-background-light transition-colors">Cancel</a>
            <button type="submit" class="px-6 py-2 bg-primary text-white rounded-lg hover:bg-blue-600 transition-colors">Update Customer</button>
        </div>
    </form>
</div>
@endsection
