@extends('layouts.app')

@section('title', 'Supplier Profile')

@section('content')
<div class="bg-gray-50 min-h-screen py-8">
    <div class="container mx-auto px-4 max-w-4xl">
        <div class="mb-8">
            <h1 class="text-3xl font-bold text-gray-900">Profile Settings</h1>
            <p class="text-gray-600">Manage your supplier profile and delivery options</p>
        </div>

        @if(session('success'))
            <div class="bg-green-50 text-green-600 px-4 py-3 rounded-lg mb-6">{{ session('success') }}</div>
        @endif

        <form action="{{ route('supplier.profile.update') }}" method="POST">
            @csrf
            @method('PUT')

            <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
                <h2 class="font-semibold text-lg mb-4">Business Information</h2>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="md:col-span-2">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Business Name *</label>
                        <input type="text" name="company_name" value="{{ old('company_name', $supplier->company_name) }}" required
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>

                    <div class="md:col-span-2">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Business Description</label>
                        <textarea name="description" rows="3"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                            placeholder="Tell customers about your business...">{{ old('description', $supplier->description) }}</textarea>
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Contact Phone</label>
                        <input type="tel" name="contact_phone" value="{{ old('contact_phone', $supplier->contact_phone) }}"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                            placeholder="+27 12 345 6789">
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Email</label>
                        <input type="email" value="{{ $supplier->contact_email }}" disabled
                            class="w-full px-4 py-2 border border-gray-200 rounded-lg bg-gray-50 text-gray-500">
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
                <h2 class="font-semibold text-lg mb-4">Business Address</h2>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="md:col-span-2">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Street Address</label>
                        <input type="text" name="address" value="{{ old('address', $supplier->address) }}"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                            placeholder="123 Business Street">
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">City</label>
                        <input type="text" name="city" value="{{ old('city', $supplier->city) }}"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                            placeholder="Johannesburg">
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Postal Code</label>
                        <input type="text" name="postal_code" value="{{ old('postal_code', $supplier->postal_code) }}"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                            placeholder="2000">
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
                <h2 class="font-semibold text-lg mb-4">Delivery Options</h2>
                
                <div class="space-y-4">
                    <label class="flex items-start p-4 border rounded-xl cursor-pointer hover:border-blue-500 transition">
                        <input type="checkbox" name="delivery_self" value="1" {{ $supplier->delivery_self ? 'checked' : '' }}
                            class="w-5 h-5 mt-0.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
                        <div class="ml-3">
                            <span class="font-medium">I can deliver to customers</span>
                            <p class="text-sm text-gray-500">You will handle delivery to customer locations</p>
                        </div>
                    </label>

                    <label class="flex items-start p-4 border rounded-xl cursor-pointer hover:border-blue-500 transition">
                        <input type="checkbox" name="delivery_collection" value="1" {{ $supplier->delivery_collection ? 'checked' : '' }}
                            class="w-5 h-5 mt-0.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
                        <div class="ml-3">
                            <span class="font-medium">Customers can collect from me</span>
                            <p class="text-sm text-gray-500">Customers can pick up orders from your location</p>
                        </div>
                    </label>

                    <label class="flex items-start p-4 border rounded-xl cursor-pointer hover:border-blue-500 transition">
                        <input type="checkbox" name="delivery_platform" value="1" {{ $supplier->delivery_platform ? 'checked' : '' }}
                            class="w-5 h-5 mt-0.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
                        <div class="ml-3">
                            <span class="font-medium">Use ProcureHub delivery service</span>
                            <p class="text-sm text-gray-500">We'll handle delivery for you (additional fees may apply)</p>
                        </div>
                    </label>
                </div>
            </div>

            <div class="flex justify-end">
                <button type="submit" class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition">
                    Save Changes
                </button>
            </div>
        </form>
    </div>
</div>
@endsection
