@extends('layouts.app')

@section('title', 'Add New Property - Admin Portal')

@section('content')
<div class="bg-slate-900 text-white py-8">
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
        <h1 class="font-heading font-extrabold text-2xl">Create New Real Estate Listing</h1>
    </div>
</div>

<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
    <div class="bg-white rounded-3xl p-8 shadow-xl border border-slate-100">
        
        <form action="{{ route('admin.properties.store') }}" method="POST" enctype="multipart/form-data" class="space-y-6">
            @csrf

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Property Title</label>
                <input type="text" name="title" required placeholder="e.g. 4-Bedroom Detached Villa in Chevron" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Price (₦)</label>
                    <input type="number" name="price" required placeholder="e.g. 150000000" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Property Type</label>
                    <select name="property_type" required class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                        <option value="Villa">Villa</option>
                        <option value="Land">Land Plot</option>
                        <option value="House">House / Duplex</option>
                        <option value="Apartment">Serviced Apartment</option>
                        <option value="Commercial">Commercial</option>
                    </select>
                </div>
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Listing Status</label>
                    <select name="status" required class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                        <option value="Buy">For Sale</option>
                        <option value="Rent">For Rent</option>
                    </select>
                </div>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Bedrooms</label>
                    <input type="number" name="bedrooms" value="0" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Bathrooms</label>
                    <input type="number" name="bathrooms" value="0" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Sqm Area</label>
                    <input type="number" name="sqft" value="0" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Address / Street</label>
                    <input type="text" name="address" required placeholder="e.g. Admiralty Way" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
                <div>
                    <label class="block text-xs font-bold text-slate-700 uppercase mb-1">City</label>
                    <input type="text" name="city" required placeholder="e.g. Lekki, Epe, Guzape" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                </div>
            </div>

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Title Document</label>
                <input type="text" name="title_document" placeholder="e.g. C of O, Governor's Consent, Gazette..." class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
            </div>

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Features (Comma Separated)</label>
                <input type="text" name="features" placeholder="e.g. Swimming Pool, 24/7 Security, Gated Community, Solar Backup" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
            </div>

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Property Description</label>
                <textarea name="description" rows="4" required class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue"></textarea>
            </div>

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Assign Agent</label>
                <select name="agent_id" class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm focus:outline-none focus:border-brand-blue">
                    <option value="">Select Agent</option>
                    @foreach($agents as $agent)
                        <option value="{{ $agent->id }}">{{ $agent->name }} ({{ $agent->title }})</option>
                    @endforeach
                </select>
            </div>

            <div>
                <label class="block text-xs font-bold text-slate-700 uppercase mb-1">Upload Property Photos</label>
                <input type="file" name="images[]" multiple class="w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm">
            </div>

            <div class="flex items-center space-x-2 pt-2">
                <input type="checkbox" name="featured" id="featured" class="w-4 h-4 text-brand-blue rounded">
                <label for="featured" class="text-sm font-bold text-slate-800">Feature this property on Home Page</label>
            </div>

            <button type="submit" class="w-full py-4 rounded-xl bg-brand-blue text-white font-extrabold text-base hover:bg-brand-darkblue shadow-lg">
                Publish Property Listing
            </button>
        </form>

    </div>
</div>
@endsection
