<?php

namespace Database\Seeders;

use App\Models\Agent;
use App\Models\Property;
use App\Models\BlogPost;
use App\Models\User;
use App\Models\Neighborhood;
use App\Models\Gallery;
use App\Models\Promotion;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        // Admin User
        User::create([
            'name' => 'Frantyapp Admin',
            'email' => 'admin@frantyapp.com',
            'password' => Hash::make('password'),
            'role' => 'admin',
        ]);

        // Agents & Agent User Logins (Official Team Roster)
        $agentData = [
            [
                'name' => 'Dr. Francis Kato David',
                'title' => 'CEO',
                'email' => 'francis.kato@frantyapp.com',
                'phone' => '08033499100',
                'whatsapp' => '+2348033499100',
                'photo' => 'assets/team/Dr. Francis Kato David.jpg',
                'bio' => 'Dr. Francis Kato David directs executive strategy, FCDA allocation verification, and institutional property acquisitions across Abuja prime districts.',
            ],
            [
                'name' => 'Martha Monday',
                'title' => 'Sales Representative',
                'email' => 'martha.monday@frantyapp.com',
                'phone' => '09167595828',
                'whatsapp' => '+2349167595828',
                'photo' => 'assets/team/Martha Monday.jpg',
                'bio' => 'Martha handles residential plot sales, client site inspections, and property allocations across Guzape, Katampe Extension, and Kubwa.',
            ],
            [
                'name' => 'Chinwe Onah',
                'title' => 'Marketing and Sales Representative',
                'email' => 'chinwe.onah@frantyapp.com',
                'phone' => '07052231269',
                'whatsapp' => '+2347052231269',
                'photo' => 'assets/team/CHINWE ONAH.jpg',
                'bio' => 'Chinwe leads client walkthroughs, luxury villa marketing, and direct developer briefs across Maitama, Asokoro, and Jabi Waterfront.',
            ],
            [
                'name' => 'Patience Ochefije Michael',
                'title' => 'Human Resource',
                'email' => 'patience.michael@frantyapp.com',
                'phone' => '08124596907',
                'whatsapp' => '+2348124596907',
                'photo' => 'assets/team/Patience Ochefije Michael.jpeg',
                'bio' => 'Patience manages human resources, corporate client relations, and site inspection scheduling at Frantyap Homes 633 Headquarters.',
            ],
            [
                'name' => 'Salihu Sadia Elizabeth',
                'title' => 'Sales and Marketing Manager',
                'email' => 'salihu.sadia@frantyapp.com',
                'phone' => '+2349051745684',
                'whatsapp' => '+2349051745684',
                'photo' => 'assets/team/Salihu Sadia Elizabeth.jpg',
                'bio' => 'Salihu coordinates sales strategies, commercial real estate marketing, and portfolio plot reservations across fast-growing FCT corridors.',
            ],
            [
                'name' => 'Emmanuel Mofam',
                'title' => 'Sales Representative',
                'email' => 'emmanuel.mofam@frantyapp.com',
                'phone' => '07035495682',
                'whatsapp' => '+2347035495682',
                'photo' => 'assets/team/Emmanuel mofam.jpg',
                'bio' => 'Emmanuel focuses on field plot surveys, physical beacon verification, and direct sales for buyers in Abuja and Lagos.',
            ],
        ];

        $agents = [];
        foreach ($agentData as $a) {
            $agentModel = Agent::create([
                'name' => $a['name'],
                'title' => $a['title'],
                'email' => $a['email'],
                'phone' => $a['phone'],
                'whatsapp' => $a['whatsapp'],
                'photo' => $a['photo'],
                'bio' => $a['bio'],
                'featured' => true,
            ]);

            User::create([
                'name' => $a['name'],
                'email' => $a['email'],
                'password' => Hash::make('password'),
                'role' => 'agent',
                'agent_id' => $agentModel->id,
            ]);

            $agents[] = $agentModel;
        }

        // Neighborhoods (Abuja and Lagos)
        Neighborhood::create([
            'name' => 'Maitama District',
            'slug' => 'maitama-district',
            'city' => 'Abuja',
            'tagline' => 'Diplomatic Precinct and Ambassadorial Mansions',
            'image' => 'assets/properties/villa.jpg',
            'description' => 'Maitama is Abuja\'s premier diplomatic district. Home to foreign embassies, federal agencies, and verified FCDA allocated ambassadorial plots.',
            'school_rating' => '4.9 / 5.0 (American International School and British Nigerian Academy)',
            'lifestyle_overview' => 'Serene tree-lined avenues, top tier fine dining, 24/7 armed diplomatic security patrols.',
            'avg_price_per_sqm' => '₦350,000 - ₦750,000 / sqm',
            'commute_cbd' => '5 Mins to Central Business District',
            'title_status' => 'FCDA Certificate of Occupancy (C of O)',
            'latitude' => 9.0882,
            'longitude' => 7.4933,
        ]);

        Neighborhood::create([
            'name' => 'Guzape Hillside',
            'slug' => 'guzape-hillside',
            'city' => 'Abuja',
            'tagline' => 'High-Elevated Architectural Smart Estates',
            'image' => 'assets/properties/duplex.jpg',
            'description' => 'Guzape offers panoramic elevated views over Central Area. Fast-growing high-yield corridor with ready dry land plots and solid infrastructure.',
            'school_rating' => '4.8 / 5.0 (Whiteplains British School and Capital Science Academy)',
            'lifestyle_overview' => 'Hillside fitness trails, private country clubs, peaceful luxury residential living.',
            'avg_price_per_sqm' => '₦200,000 - ₦450,000 / sqm',
            'commute_cbd' => '10 Mins to CBD',
            'title_status' => 'AGIS Verified Title and FCDA C of O',
            'latitude' => 9.0345,
            'longitude' => 7.5212,
        ]);

        Neighborhood::create([
            'name' => 'Katampe Extension',
            'slug' => 'katampe-extension',
            'city' => 'Abuja',
            'tagline' => 'Master-Planned Quiet Luxury Layouts',
            'image' => 'assets/inspection/IMG-20260506-WA0006.jpg',
            'description' => 'Katampe Extension is a government-allocated residential layout with underground drainage, wide asphalt roads, and instant building approval.',
            'school_rating' => '4.7 / 5.0 (Pace Setters College and Premier International School)',
            'lifestyle_overview' => 'Master-planned infrastructure, quiet residential neighborhood, underground drainage.',
            'avg_price_per_sqm' => '₦180,000 - ₦380,000 / sqm',
            'commute_cbd' => '12 Mins to CBD',
            'title_status' => 'FCDA Allocation Certificate',
            'latitude' => 9.1123,
            'longitude' => 7.4678,
        ]);

        Neighborhood::create([
            'name' => 'Jabi Waterfront',
            'slug' => 'jabi-waterfront',
            'city' => 'Abuja',
            'tagline' => 'Waterfront Penthouse and Leisure District',
            'image' => 'assets/properties/penthouse.jpg',
            'description' => 'Jabi Lake corridor combines waterfront residential apartments, Jabi Lake Mall proximity, boat clubs, and high rental yield investments.',
            'school_rating' => '4.8 / 5.0 (Tender Years Academy and Lead British International)',
            'lifestyle_overview' => 'Waterfront boardwalks, Jabi Lake Mall, jet-ski clubs, luxury penthouses.',
            'avg_price_per_sqm' => '₦250,000 - ₦550,000 / sqm',
            'commute_cbd' => '8 Mins to CBD',
            'title_status' => 'AGIS C of O Title',
            'latitude' => 9.0722,
            'longitude' => 7.4289,
        ]);

        // Properties (Lands photos used EXCLUSIVELY for land listings!)
        Property::create([
            'title' => '5-Bedroom Fully Detached Smart Villa with BQ',
            'slug' => '5-bedroom-fully-detached-smart-villa-with-bq',
            'description' => 'Solidly built 5-bedroom fully detached smart villa in a gated estate off Gana Street, Maitama. Features private swimming pool, fitted Italian kitchen, 2-room staff quarters, and 24/7 solar backup. FCDA C of O verified at AGIS.',
            'price' => 280000000.00,
            'property_type' => 'Villa',
            'status' => 'Buy',
            'featured' => true,
            'bedrooms' => 5,
            'bathrooms' => 6,
            'sqft' => 450,
            'address' => 'Off Gana Street, Maitama',
            'city' => 'Abuja',
            'state' => 'Abuja (FCT)',
            'country' => 'Nigeria',
            'title_document' => 'FCDA C of O',
            'features' => ['FCDA C of O Title', 'Private Swimming Pool', 'Boys Quarters (BQ)', 'Solar Power Backup', 'Smart Home Automation', '3 Mins to Transcorp Hilton'],
            'images' => [
                'assets/properties/villa.jpg',
                'assets/properties/IMG-20260825-WA0026(1).jpg'
            ],
            'agent_id' => $agents[2]->id, // Chinwe Onah
        ]);

        Property::create([
            'title' => '500sqm Hillside Residential Plot (Ready to Build)',
            'slug' => '500sqm-hillside-residential-plot-ready-to-build',
            'description' => 'Verified 500sqm dry residential land plot in Guzape Hillside layout. Survey beacons already set, tarred access road, and underground drainage in place. Approved for immediate building plan submission. Flexible payment plan available.',
            'price' => 95000000.00,
            'property_type' => 'Land',
            'status' => 'Buy',
            'featured' => true,
            'bedrooms' => 0,
            'bathrooms' => 0,
            'sqft' => 500,
            'address' => 'Hillside District, Guzape',
            'city' => 'Abuja',
            'state' => 'Abuja (FCT)',
            'country' => 'Nigeria',
            'title_document' => 'AGIS Verified C of O',
            'features' => ['AGIS Verified C of O', 'Dry Land Ready to Build', 'Survey Beacons Placed', 'Tarred Access Road', '30% Deposit Flexi-Pay', 'Hillside View'],
            'images' => [
                'assets/lands/WhatsApp Image 2026-08-26 at 14.56.35.jpeg',
                'assets/lands/WhatsApp Image 2026-08-26 at 14.56.36.jpeg',
                'assets/lands/WhatsApp Image 2026-08-26 at 14.56.37.jpeg'
            ],
            'agent_id' => $agents[1]->id, // Martha Monday
        ]);

        Property::create([
            'title' => '4-Bedroom Semi-Detached Duplex with Ante-Room',
            'slug' => '4-bedroom-semi-detached-duplex-with-ante-room',
            'description' => 'Spacious 4-bedroom duplex with ante-room, family lounge, stamp concrete compound, water treatment system, and balcony views. Located in a flood-free, secured layout in Katampe Extension, Abuja.',
            'price' => 140000000.00,
            'property_type' => 'House',
            'status' => 'Buy',
            'featured' => true,
            'bedrooms' => 4,
            'bathrooms' => 5,
            'sqft' => 320,
            'address' => 'Katampe Extension Layout',
            'city' => 'Abuja',
            'state' => 'Abuja (FCT)',
            'country' => 'Nigeria',
            'title_document' => 'FCDA Allocation Certificate',
            'features' => ['FCDA Allocation Certificate', 'Stamp Concrete Compound', 'Water Treatment System', 'All Rooms En-Suite', 'Balcony Views', '10 Mins to Central Area'],
            'images' => [
                'assets/properties/duplex.jpg',
                'assets/properties/IMG-20260825-WA0026(1).jpg'
            ],
            'agent_id' => $agents[5]->id, // Emmanuel Mofam
        ]);

        Property::create([
            'title' => '3-Bedroom Lakeview Penthouse Apartment',
            'slug' => '3-bedroom-lakeview-penthouse-apartment',
            'description' => 'Serviced 3-bedroom penthouse apartment for annual lease along Jabi Lake promenade. Features elevator access, 24/7 power supply, resident gym, swimming pool, and underground basement parking.',
            'price' => 18000000.00,
            'property_type' => 'Apartment',
            'status' => 'Rent',
            'featured' => true,
            'bedrooms' => 3,
            'bathrooms' => 3,
            'sqft' => 280,
            'address' => 'Jabi Lake Promenade',
            'city' => 'Abuja',
            'state' => 'Abuja (FCT)',
            'country' => 'Nigeria',
            'title_document' => 'Tenancy Agreement',
            'features' => ['Lakeview Balcony', 'Uninterrupted 24/7 Power', 'High Speed Elevator', 'Gym and Pool', 'Keycard Access', 'Basement Parking'],
            'images' => [
                'assets/properties/penthouse.jpg',
                'assets/properties/apartment.jpg'
            ],
            'agent_id' => $agents[4]->id, // Salihu Sadia Elizabeth
        ]);

        // Additional Bare Land Listing using assets/lands photos
        Property::create([
            'title' => 'Katampe Extension 1000sqm Commercial Plot',
            'slug' => 'katampe-extension-1000sqm-commercial-plot',
            'description' => 'Prime 1000sqm commercial land plot along main express corridor in Katampe Extension layout. Complete with survey beacons, FCDA allocation, and ready AGIS search clearance.',
            'price' => 185000000.00,
            'property_type' => 'Land',
            'status' => 'Buy',
            'featured' => true,
            'bedrooms' => 0,
            'bathrooms' => 0,
            'sqft' => 1000,
            'address' => 'Main Express Corridor, Katampe Extension',
            'city' => 'Abuja',
            'state' => 'Abuja (FCT)',
            'country' => 'Nigeria',
            'title_document' => 'FCDA Allocation C of O',
            'features' => ['Commercial Plot Title', 'Direct Main Road Access', 'Underground Utilities', 'AGIS Search Clear', 'High Capital Yield'],
            'images' => [
                'assets/lands/WhatsApp Image 2026-08-26 at 14.56.36 (1).jpeg',
                'assets/lands/WhatsApp Image 2026-08-26 at 14.56.37.jpeg'
            ],
            'agent_id' => $agents[0]->id, // Dr. Francis Kato David
        ]);

        // Blog Posts
        BlogPost::create([
            'title' => 'Navigating AGIS Search and FCDA Land Titling in Abuja (2026 Guide)',
            'slug' => 'navigating-agis-search-fcda-land-titling-abuja',
            'category' => 'Land Verification',
            'excerpt' => 'Understanding Certificate of Occupancy (C of O), Right of Occupancy (R-of-O), and AGIS search procedures before purchasing land in Abuja.',
            'content' => 'Investing in land in Abuja requires rigorous title verification at the Abuja Geographic Information Systems (AGIS). In this guide, Dr. Francis Kato David explains the step-by-step verification process.',
            'image' => 'assets/lands/WhatsApp Image 2026-08-26 at 14.56.35.jpeg',
            'author' => 'Dr. Francis Kato David',
            'featured' => true,
        ]);

        BlogPost::create([
            'title' => 'Why Guzape and Katampe Extension are Abuja\'s Top ROI Investment Corridors',
            'slug' => 'why-guzape-katampe-extension-top-roi-investment-corridors-abuja',
            'category' => 'Market Insights',
            'excerpt' => 'An in-depth review of infrastructure expansion, capital appreciation rates, and demand for hillside smart estates in Guzape.',
            'content' => 'Abuja real estate continues to deliver double-digit annual appreciation. Infrastructure development in Guzape and Katampe Extension has driven property values up by over 28% year-on-year.',
            'image' => 'assets/properties/villa.jpg',
            'author' => 'Chinwe Onah',
            'featured' => true,
        ]);

        // Photo Gallery Albums (Site Inspection & Team Photos)
        $inspectionPhotos = [
            ['title' => 'Beacon Verification at Katampe Extension Site', 'image' => 'assets/inspection/IMG-20260506-WA0006.jpg'],
            ['title' => 'Guzape Hillside Plot Survey & Boundary Clearance', 'image' => 'assets/inspection/IMG-20260506-WA0007.jpg'],
            ['title' => 'Field Inspection of Perimeter Infrastructure', 'image' => 'assets/inspection/IMG-20260506-WA0008.jpg'],
            ['title' => 'AGIS Cadastral Survey Alignment Assessment', 'image' => 'assets/inspection/IMG-20260506-WA0010.jpg'],
            ['title' => 'Client Site Walkthrough in Kubwa Layout', 'image' => 'assets/inspection/IMG-20260506-WA0013.jpg'],
            ['title' => 'On-Site Topographical Ground Inspection', 'image' => 'assets/inspection/IMG-20260508-WA0007.jpg'],
        ];

        foreach ($inspectionPhotos as $p) {
            Gallery::create([
                'title' => $p['title'],
                'category' => 'Site Inspection',
                'image' => $p['image'],
                'description' => 'Frantyapp field team carrying out physical inspection, survey verification, and client walkthroughs.',
                'featured' => true,
            ]);
        }

        $teamPhotos = [
            ['title' => 'Frantyap Advisors Executive Strategy Session', 'image' => 'assets/team/IMG-20260825-WA0063.jpg.jpeg'],
            ['title' => 'Field Operations & Site Walkthrough Coordination', 'image' => 'assets/team/IMG-20260825-WA0088.jpg.jpeg'],
            ['title' => 'Client Relation Advisory Team Briefing', 'image' => 'assets/team/IMG-20260825-WA0090.jpg.jpeg'],
            ['title' => 'Senior Real Estate Consultants Meeting', 'image' => 'assets/team/IMG-20260825-WA0094.jpg.jpeg'],
            ['title' => 'Abuja Regional Portfolio Strategy Meeting', 'image' => 'assets/team/IMG-20260825-WA0095.jpg.jpeg'],
            ['title' => 'Field Survey & Inspection Team On-Site', 'image' => 'assets/team/IMG-20260825-WA0106.jpg.jpeg'],
        ];

        foreach ($teamPhotos as $tp) {
            Gallery::create([
                'title' => $tp['title'],
                'category' => 'Team Operations',
                'image' => $tp['image'],
                'description' => 'Frantyap Homes executive and field operations team in action across FCT Abuja.',
                'featured' => true,
            ]);
        }

        // Homepage Major Promotions Carousel Slides
        Promotion::create([
            'title' => 'Frantyap Homes Estate - Arab Road Kubwa Abuja',
            'subtitle' => 'Land and Foundation (Suitable for 4-Bedroom Terrace Duplex)',
            'badge' => 'Kubwa Special Offer',
            'price_tag' => '₦30M - ₦120M',
            'image' => 'assets/promotions/kubwa_estate.png',
            'location' => 'Arab Road, Kubwa, Abuja (3 Mins to Railway Station)',
            'features' => ['FCDA Approved R of O', 'Perimeter Fence', 'Asphalt Access Road', '24HRS Water and Electricity', 'Private Transformer'],
            'cta_text' => 'Reserve Plot / Carcass Now',
            'cta_link' => route('contact'),
            'order' => 1,
            'active' => true,
        ]);

        Promotion::create([
            'title' => 'Guzape Hillside Residential Plots (500sqm)',
            'subtitle' => 'Verified Dry Land Plots Ready for Immediate Building Plan Approval',
            'badge' => 'High ROI Investment',
            'price_tag' => '₦95,000,000',
            'image' => 'assets/promotions/guzape_land.png',
            'location' => 'Hillside Precinct, Guzape, Abuja',
            'features' => ['AGIS Verified C of O', 'Panoramic CBD View', 'Underground Drainage', 'Tarred Roads', '24/7 Security'],
            'cta_text' => 'Schedule Land Inspection',
            'cta_link' => route('contact'),
            'order' => 2,
            'active' => true,
        ]);

        // Site Settings (Extracted from Official Flyer)
        \App\Models\SiteSetting::set('company_name', 'Frantyap Homes 633');
        \App\Models\SiteSetting::set('company_phone', '09126262525 / 08065351599');
        \App\Models\SiteSetting::set('whatsapp_number', '+2349126262525');
        \App\Models\SiteSetting::set('company_email', 'frantyaphomes633@gmail.com');
        \App\Models\SiteSetting::set('office_address', 'Suite 11, First Floor Eastley Park Plaza, No 5 Bathurst Street off Aminu Kano Crescent, Wuse 2, FCT-Abuja');
        \App\Models\SiteSetting::set('hero_title', 'Find your place in Abuja.');
        \App\Models\SiteSetting::set('hero_subtitle', 'Discover verified FCDA land titles, diplomatic villas, duplexes, and prime investments across Maitama, Asokoro, Guzape, Katampe, and Kubwa.');
    }
}
