@extends('layouts.app')
@section('title','Create New Lead — HIGHRA CRM')
@section('header','Create New Lead')

@section('content')
<div style="max-width: 800px;">
    <div style="font-size: 13px; color: #8e9ab4; margin-bottom: 8px;">
        <a href="{{ route('leads.index') }}" style="color: #6d59ff; text-decoration: none;">← Back to Leads List</a>
    </div>
    
    <div class="panel" style="margin-top: 0;">
        <h2 style="margin-top: 0; padding-bottom: 12px; border-bottom: 1px solid #202b47; color: #fff;">
            Lead Registration Details
        </h2>

        <form method="POST" action="{{ route('leads.store') }}">
            @csrf

            <div class="grid2">
                <div>
                    <label>Lead / Contact Name *</label>
                    <input type="text" name="name" value="{{ old('name') }}" required placeholder="e.g. John Doe">
                </div>

                <div>
                    <label>Company Name</label>
                    <input type="text" name="company" value="{{ old('company') }}" placeholder="e.g. Acme Corp">
                </div>

                <div>
                    <label>Phone Number</label>
                    <input type="text" name="phone" value="{{ old('phone') }}" placeholder="e.g. +1 555-0199">
                </div>

                <div>
                    <label>Email Address</label>
                    <input type="email" name="email" value="{{ old('email') }}" placeholder="e.g. john@example.com">
                </div>

                <div>
                    <label>Lead Source *</label>
                    <select name="source" required>
                        <option value="manual">Manual Entry</option>
                        <option value="website">Website Form</option>
                        <option value="facebook">Facebook Lead Ads</option>
                        <option value="instagram">Instagram Ads</option>
                        <option value="whatsapp">WhatsApp Inquiry</option>
                        <option value="referral">Referral</option>
                    </select>
                </div>

                <div>
                    <label>Pipeline Status *</label>
                    <select name="status" required>
                        <option value="new">New</option>
                        <option value="contacted">Contacted</option>
                        <option value="qualified">Qualified</option>
                        <option value="won">Won</option>
                        <option value="lost">Lost</option>
                    </select>
                </div>

                <div>
                    <label>Assign Executive</label>
                    <select name="assigned_to">
                        <option value="">Unassigned</option>
                        @if(isset($users))
                            @foreach($users as $user)
                                <option value="{{ $user->id }}">{{ $user->name }} ({{ ucfirst($user->role) }})</option>
                            @endforeach
                        @endif
                    </select>
                </div>

                <div>
                    <label>Expected Deal Value (₹)</label>
                    <input type="number" step="0.01" name="expected_value" value="{{ old('expected_value') }}" placeholder="e.g. 50000.00">
                </div>
            </div>

            <div style="margin-top: 16px;">
                <label>Lead Notes & Description</label>
                <textarea name="notes" placeholder="Add relevant details, product interests, or requirements...">{{ old('notes') }}</textarea>
            </div>

            <div style="display: flex; gap: 12px; margin-top: 24px; padding-top: 16px; border-top: 1px solid #202b47;">
                <button type="submit" class="btn">Create Lead</button>
                <a href="{{ route('leads.index') }}" class="btn btn-secondary" style="text-decoration: none;">Cancel</a>
            </div>
        </form>
    </div>
</div>
@endsection
