@extends('layouts.app')

@section('title', 'Nova oportunidade — ImóvelZapAi')
@section('page-title', 'Nova oportunidade')

@section('content')
    @include('partials.flash')

    <div class="mx-auto max-w-xl rounded-xl border border-slate-200 bg-white p-6 shadow-sm">
        <form method="POST" action="{{ route('sales.store') }}" class="space-y-4">
            @csrf
            <label class="block text-sm">
                <span class="mb-1 block font-medium text-slate-700">Pessoa (contact_id)</span>
                <input type="text" name="contact_id" value="{{ old('contact_id', $contactId) }}"
                    class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </label>
            <label class="block text-sm">
                <span class="mb-1 block font-medium text-slate-700">Conversa (opcional)</span>
                <input type="text" name="conversation_id" value="{{ old('conversation_id', $conversationId) }}"
                    class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </label>
            <label class="block text-sm">
                <span class="mb-1 block font-medium text-slate-700">Imóvel (opcional)</span>
                <input type="text" name="property_id" value="{{ old('property_id', $propertyId) }}"
                    class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </label>
            <label class="block text-sm">
                <span class="mb-1 block font-medium text-slate-700">Valor</span>
                <input type="number" step="0.01" name="amount" value="{{ old('amount') }}"
                    class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </label>
            <label class="block text-sm">
                <span class="mb-1 block font-medium text-slate-700">Prioridade</span>
                <select name="priority" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
                    @foreach ($priorities as $p)
                        <option value="{{ $p->value }}">{{ $p->label() }}</option>
                    @endforeach
                </select>
            </label>
            @error('deal')<p class="text-sm text-red-600">{{ $message }}</p>@enderror
            <button type="submit" class="rounded-lg bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500">Criar</button>
        </form>
    </div>
@endsection
