@extends('layouts.aura-main')

@section('main-content')
<div x-data="{ loading: false }">
    <div class="mb-8 border-b border-slate-200 pb-4 flex justify-between items-end">
        <div>
            <h1 class="text-2xl font-bold text-slate-900 tracking-tight">New Customer</h1>
            <p class="text-[11px] font-bold text-indigo-600">Onboarding & credit profile</p>
        </div>
        <div class="flex items-center gap-3">
            <a href="{{ route('customers.index') }}" class="text-[11px] font-bold text-slate-400 px-4 py-2 hover:text-slate-600 transition">Cancel</a>
            <button type="submit" form="customer-form" :disabled="loading" class="bg-indigo-600 text-white px-8 py-2 rounded-sm text-[11px] font-bold shadow-sm hover:bg-indigo-700 transition">
                <span x-text="loading ? 'Saving...' : 'Onboard Customer'"></span>
            </button>
        </div>
    </div>

    <form id="customer-form" action="{{ route('customers.store') }}" method="POST" @submit="loading = true">
        @csrf

        <div class="space-y-6">
            <div class="bg-white border border-slate-300 rounded-sm shadow-sm p-6">
                <h2 class="text-[11px] font-bold text-indigo-600 mb-6 flex items-center gap-2">
                    <div class="w-1.5 h-4 bg-indigo-500 rounded-full"></div>
                    Business Information
                </h2>
                
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">
                    <div class="lg:col-span-2">
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Company / Customer Name *</label>
                        <input type="text" name="name" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm" required>
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">TPIN (Tax ID)</label>
                        <input type="text" name="tpin" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm font-mono">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Business Phone</label>
                        <input type="text" name="phone" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm">
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 pt-4 border-t border-slate-50">
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Physical Address</label>
                        <textarea name="physical_address" rows="2" class="w-full border border-slate-300 rounded-sm p-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm" placeholder="Street, City..."></textarea>
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Postal Address</label>
                        <textarea name="postal_address" rows="2" class="w-full border border-slate-300 rounded-sm p-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm" placeholder="P.O Box..."></textarea>
                    </div>
                </div>
            </div>

            <div class="bg-white border border-slate-300 rounded-sm shadow-sm p-6">
                <h2 class="text-[11px] font-bold text-indigo-600 mb-6 flex items-center gap-2">
                    <div class="w-1.5 h-4 bg-emerald-500 rounded-full"></div>
                    Primary Contact Person
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">First Name</label>
                        <input type="text" name="contact_first_name" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Last Name</label>
                        <input type="text" name="contact_last_name" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Country</label>
                        <input type="text" name="country" value="Zambia" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition font-bold shadow-sm">
                    </div>
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Contact Email</label>
                        <input type="email" name="contact_email" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Contact Phone</label>
                        <input type="text" name="contact_phone" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm">
                    </div>
                </div>
            </div>

            <div class="bg-white border border-slate-300 rounded-sm shadow-sm p-6">
                <h2 class="text-[11px] font-bold text-indigo-600 mb-6 flex items-center gap-2">
                    <div class="w-1.5 h-4 bg-amber-500 rounded-full"></div>
                    Financial & credit profile
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Opening Balance (K)</label>
                        <input type="number" step="0.01" name="opening_balance" value="0.00" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none font-mono font-bold focus:border-indigo-500 shadow-sm">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Credit Limit (K)</label>
                        <input type="number" step="0.01" name="credit_limit" value="0.00" class="w-full border border-slate-300 rounded-sm px-3 py-2 text-xs outline-none font-mono font-bold focus:border-indigo-500 shadow-sm text-red-600">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 mb-1">Internal Notes</label>
                        <textarea name="notes" rows="1" class="w-full border border-slate-300 rounded-sm p-2 text-xs outline-none focus:border-indigo-500 transition shadow-sm" placeholder="Terms, lead times..."></textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
@endsection