import 'dotenv/config'
import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import bcrypt from 'bcryptjs'

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! })
const prisma = new PrismaClient({ adapter })

async function main() {
  console.log('🌱 Seeding database with comprehensive demo data...\n')

  // ============================================================
  // PHASE 1: CLEAN ALL DATA (reverse dependency order)
  // ============================================================
  console.log('🗑️  Cleaning existing data...')

  await prisma.notification.deleteMany({})
  await prisma.auditLog.deleteMany({})
  await prisma.dailyOperation.deleteMany({})
  await prisma.fundAllocation.deleteMany({})
  await prisma.payment.deleteMany({})
  await prisma.bookingItem.deleteMany({})
  await prisma.itineraryDay.deleteMany({})
  await prisma.booking.deleteMany({})
  await prisma.quoteItem.deleteMany({})
  await prisma.quote.deleteMany({})
  await prisma.queryDestination.deleteMany({})
  await prisma.query.deleteMany({})
  await prisma.activitySlot.deleteMany({})
  await prisma.activity.deleteMany({})
  await prisma.transportPricing.deleteMany({})
  await prisma.transportRoute.deleteMany({})
  await prisma.driver.deleteMany({})
  await prisma.transportVehicle.deleteMany({})
  await prisma.roomPricing.deleteMany({})
  await prisma.roomType.deleteMany({})
  await prisma.hotel.deleteMany({})
  await prisma.supplierDocument.deleteMany({})
  await prisma.supplier.deleteMany({})
  await prisma.tripSource.deleteMany({})
  await prisma.companySettings.deleteMany({})

  console.log('   ✓ All data cleaned\n')

  // ============================================================
  // PHASE 2: USERS (upsert to keep existing)
  // ============================================================
  console.log('👤 Creating users...')

  const passwordHash = await bcrypt.hash('admin123', 12)

  const admin = await prisma.user.upsert({
    where: { email: 'admin@dmcify.com' },
    update: { passwordHash },
    create: {
      email: 'admin@dmcify.com',
      name: 'Admin User',
      passwordHash,
      role: 'ADMIN',
      phone: '+971501000001',
    },
  })

  const opsUser = await prisma.user.upsert({
    where: { email: 'ops@dmcify.com' },
    update: { passwordHash },
    create: {
      email: 'ops@dmcify.com',
      name: 'Operations Manager',
      passwordHash,
      role: 'OPERATIONS',
      phone: '+971501000002',
    },
  })

  const salesUser = await prisma.user.upsert({
    where: { email: 'sales@dmcify.com' },
    update: { passwordHash },
    create: {
      email: 'sales@dmcify.com',
      name: 'Sales Executive',
      passwordHash,
      role: 'SALES',
      phone: '+971501000003',
    },
  })

  const financeUser = await prisma.user.upsert({
    where: { email: 'finance@dmcify.com' },
    update: { passwordHash },
    create: {
      email: 'finance@dmcify.com',
      name: 'Finance Manager',
      passwordHash,
      role: 'FINANCE',
      phone: '+971501000004',
    },
  })

  const allUsers = [admin, opsUser, salesUser, financeUser]
  console.log(`   ✓ ${allUsers.length} users created\n`)

  // ============================================================
  // PHASE 3: DESTINATIONS (upsert by name)
  // ============================================================
  console.log('🌍 Creating destinations...')

  const dubaiDest = await prisma.destination.upsert({
    where: { name: 'Dubai City' },
    update: {},
    create: { name: 'Dubai City', country: 'UAE', city: 'Dubai', currency: 'AED', timezone: 'Asia/Dubai', visaRequired: true, visaRequirements: 'Visa on arrival for most nationalities' },
  })

  const abuDhabiDest = await prisma.destination.upsert({
    where: { name: 'Abu Dhabi' },
    update: {},
    create: { name: 'Abu Dhabi', country: 'UAE', city: 'Abu Dhabi', currency: 'AED', timezone: 'Asia/Dubai', visaRequired: true },
  })

  const baliDest = await prisma.destination.upsert({
    where: { name: 'Bali' },
    update: {},
    create: { name: 'Bali', country: 'Indonesia', city: 'Denpasar', currency: 'IDR', timezone: 'Asia/Makassar', visaRequired: false },
  })

  const bangkokDest = await prisma.destination.upsert({
    where: { name: 'Bangkok' },
    update: {},
    create: { name: 'Bangkok', country: 'Thailand', city: 'Bangkok', currency: 'THB', timezone: 'Asia/Bangkok', visaRequired: false },
  })

  const singaporeDest = await prisma.destination.upsert({
    where: { name: 'Singapore' },
    update: {},
    create: { name: 'Singapore', country: 'Singapore', city: 'Singapore', currency: 'SGD', timezone: 'Asia/Singapore', visaRequired: false },
  })

  const maldivesDest = await prisma.destination.upsert({
    where: { name: 'Maldives' },
    update: {},
    create: { name: 'Maldives', country: 'Maldives', city: 'Male', currency: 'USD', timezone: 'Indian/Maldives', visaRequired: false, visaRequirements: '30-day free visa on arrival' },
  })

  console.log('   ✓ 6 destinations created\n')

  // ============================================================
  // PHASE 4: TRIP SOURCES
  // ============================================================
  console.log('📡 Creating trip sources...')

  const tsTravelMax = await prisma.tripSource.create({
    data: { name: 'TravelMax Agency', type: 'B2B_AGENT', contactPerson: 'John Smith', email: 'john@travelmax.com', phone: '+971551112233', commissionRate: 10, commissionType: 'PERCENTAGE' },
  })

  const tsGlobeTrotters = await prisma.tripSource.create({
    data: { name: 'Globe Trotters Inc', type: 'B2B_AGENT', contactPerson: 'Sarah Johnson', email: 'sarah@globetrotters.com', phone: '+971552223344', commissionRate: 12, commissionType: 'PERCENTAGE' },
  })

  const tsWebsite = await prisma.tripSource.create({
    data: { name: 'Company Website', type: 'WEBSITE' },
  })

  const tsInstagram = await prisma.tripSource.create({
    data: { name: 'Instagram Leads', type: 'SOCIAL_MEDIA', notes: 'Leads from @dmcify_travel' },
  })

  const tsWalkIn = await prisma.tripSource.create({
    data: { name: 'Walk-in Office', type: 'WALK_IN', address: 'Business Bay, Dubai, UAE' },
  })

  const tsReferral = await prisma.tripSource.create({
    data: { name: 'Friend Referral', type: 'REFERRAL' },
  })

  const allTripSources = [tsTravelMax, tsGlobeTrotters, tsWebsite, tsInstagram, tsWalkIn, tsReferral]
  console.log(`   ✓ ${allTripSources.length} trip sources created\n`)

  // ============================================================
  // PHASE 5: NUMBER SERIES (upsert, reset nextNumber)
  // ============================================================
  console.log('🔢 Creating number series...')

  const numberSeriesData = [
    { prefix: 'QRY', module: 'queries', docType: 'QUERY', nextNumber: 26 },
    { prefix: 'QOT', module: 'quotes', docType: 'QUOTE', nextNumber: 7 },
    { prefix: 'BKG', module: 'bookings', docType: 'BOOKING', nextNumber: 16 },
    { prefix: 'PAY', module: 'payments', docType: 'PAYMENT', nextNumber: 13 },
    { prefix: 'SUP', module: 'suppliers', docType: 'SUPPLIER', nextNumber: 9 },
  ]

  for (const ns of numberSeriesData) {
    await prisma.numberSeries.upsert({
      where: { module_docType: { module: ns.module, docType: ns.docType } },
      update: { nextNumber: ns.nextNumber },
      create: ns,
    })
  }
  console.log('   ✓ 5 number series created\n')

  // ============================================================
  // PHASE 6: SUPPLIERS
  // ============================================================
  console.log('🏢 Creating suppliers...')

  const supDesertEagle = await prisma.supplier.create({
    data: {
      code: 'SUP-001', name: 'Desert Eagle Transport', type: 'TRANSPORT',
      contactPerson: 'Ali Hassan', email: 'ali@deserteagle.ae', phone: '+971501234001',
      city: 'Dubai', country: 'UAE', contractStart: new Date('2025-01-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  const supBayTransfers = await prisma.supplier.create({
    data: {
      code: 'SUP-002', name: 'Bay Transfers LLC', type: 'TRANSPORT',
      contactPerson: 'Omar Khalil', email: 'omar@baytransfers.ae', phone: '+971501234002',
      city: 'Abu Dhabi', country: 'UAE', contractStart: new Date('2025-01-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  const supIslandShuttles = await prisma.supplier.create({
    data: {
      code: 'SUP-003', name: 'Island Shuttles', type: 'TRANSPORT',
      contactPerson: 'Nyoman Surya', email: 'info@islandshuttles.id', phone: '+6281234500003',
      city: 'Denpasar', country: 'Indonesia', contractStart: new Date('2025-03-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  const supGrandStays = await prisma.supplier.create({
    data: {
      code: 'SUP-004', name: 'Grand Stays Hospitality', type: 'HOTEL',
      contactPerson: 'Fatima Al Mazrouei', email: 'fatima@grandstays.ae', phone: '+971501234004',
      city: 'Dubai', country: 'UAE', contractStart: new Date('2025-01-01'), contractEnd: new Date('2027-03-31'),
    },
  })

  const supParadiseResorts = await prisma.supplier.create({
    data: {
      code: 'SUP-005', name: 'Paradise Resorts Group', type: 'HOTEL',
      contactPerson: 'Ibrahim Nashid', email: 'ibrahim@paradiseresorts.mv', phone: '+9607001234',
      city: 'Male', country: 'Maldives', contractStart: new Date('2025-06-01'), contractEnd: new Date('2027-05-31'),
    },
  })

  const supAsianHotels = await prisma.supplier.create({
    data: {
      code: 'SUP-006', name: 'Asian Hotels Alliance', type: 'HOTEL',
      contactPerson: 'Somchai Lek', email: 'somchai@asianhotels.th', phone: '+66891234567',
      city: 'Bangkok', country: 'Thailand', contractStart: new Date('2025-02-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  const supAdventureWorld = await prisma.supplier.create({
    data: {
      code: 'SUP-007', name: 'Adventure World', type: 'ACTIVITY',
      contactPerson: 'Ravi Kumar', email: 'ravi@adventureworld.ae', phone: '+971501234007',
      city: 'Dubai', country: 'UAE', contractStart: new Date('2025-01-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  const supTropicalExcursions = await prisma.supplier.create({
    data: {
      code: 'SUP-008', name: 'Tropical Excursions', type: 'ACTIVITY',
      contactPerson: 'Wayan Putu', email: 'wayan@tropicalexcursions.id', phone: '+6281234500008',
      city: 'Denpasar', country: 'Indonesia', contractStart: new Date('2025-04-01'), contractEnd: new Date('2026-12-31'),
    },
  })

  console.log('   ✓ 8 suppliers created\n')

  // ============================================================
  // PHASE 7: TRANSPORT VEHICLES (2 per transport supplier)
  // ============================================================
  console.log('🚗 Creating transport vehicles...')

  // Desert Eagle vehicles
  const vehDE1 = await prisma.transportVehicle.create({
    data: { supplierId: supDesertEagle.id, vehicleType: 'SEDAN', name: 'Toyota Camry', capacity: 3, registrationNo: 'DXB-A-11234' },
  })
  const vehDE2 = await prisma.transportVehicle.create({
    data: { supplierId: supDesertEagle.id, vehicleType: 'SUV', name: 'Toyota Land Cruiser', capacity: 6, registrationNo: 'DXB-B-55678' },
  })

  // Bay Transfers vehicles
  const vehBT1 = await prisma.transportVehicle.create({
    data: { supplierId: supBayTransfers.id, vehicleType: 'VAN', name: 'Mercedes Vito', capacity: 7, registrationNo: 'AUH-C-22345' },
  })
  const vehBT2 = await prisma.transportVehicle.create({
    data: { supplierId: supBayTransfers.id, vehicleType: 'MINIBUS', name: 'Toyota Coaster', capacity: 15, registrationNo: 'AUH-D-33456' },
  })

  // Island Shuttles vehicles
  const vehIS1 = await prisma.transportVehicle.create({
    data: { supplierId: supIslandShuttles.id, vehicleType: 'SEDAN', name: 'Honda Civic', capacity: 3, registrationNo: 'BA-1234-XY' },
  })
  const vehIS2 = await prisma.transportVehicle.create({
    data: { supplierId: supIslandShuttles.id, vehicleType: 'VAN', name: 'Toyota HiAce', capacity: 8, registrationNo: 'BA-5678-ZZ' },
  })

  console.log('   ✓ 6 transport vehicles created (Note: 2 extra SUV + MINIBUS)\n')

  // ============================================================
  // PHASE 8: DRIVERS (linked to transport suppliers + vehicles)
  // ============================================================
  console.log('🧑‍✈️ Creating drivers...')

  const driverAhmed = await prisma.driver.create({
    data: { name: 'Ahmed Al Rashid', phone: '+971501112233', supplierId: supDesertEagle.id, vehicleId: vehDE1.id, licenseNumber: 'DXB-12345', licenseExpiry: new Date('2026-06-30') },
  })

  const driverMohammed = await prisma.driver.create({
    data: { name: 'Mohammed Saeed', phone: '+971502223344', supplierId: supDesertEagle.id, vehicleId: vehDE2.id, licenseNumber: 'DXB-12346', licenseExpiry: new Date('2027-01-15') },
  })

  const driverKhalid = await prisma.driver.create({
    data: { name: 'Khalid Noor', phone: '+971503334455', supplierId: supBayTransfers.id, vehicleId: vehBT1.id, licenseNumber: 'AUH-78901', licenseExpiry: new Date('2026-09-30') },
  })

  const driverRashid = await prisma.driver.create({
    data: { name: 'Rashid Abdullah', phone: '+971504445566', supplierId: supBayTransfers.id, vehicleId: vehBT2.id, licenseNumber: 'AUH-78902', licenseExpiry: new Date('2026-12-31') },
  })

  const driverMade = await prisma.driver.create({
    data: { name: 'Made Wayan', phone: '+6281234567890', supplierId: supIslandShuttles.id, vehicleId: vehIS1.id, licenseNumber: 'BALI-001', licenseExpiry: new Date('2027-03-15') },
  })

  const driverKetut = await prisma.driver.create({
    data: { name: 'Ketut Dharma', phone: '+6281234567891', supplierId: supIslandShuttles.id, vehicleId: vehIS2.id, licenseNumber: 'BALI-002', licenseExpiry: new Date('2026-11-30') },
  })

  const allDrivers = [driverAhmed, driverMohammed, driverKhalid, driverRashid, driverMade, driverKetut]
  console.log(`   ✓ ${allDrivers.length} drivers created\n`)

  // ============================================================
  // PHASE 9: HOTELS (8 hotels across destinations)
  // ============================================================
  console.log('🏨 Creating hotels...')

  // Dubai hotels
  const hotelJumeirah = await prisma.hotel.create({
    data: {
      name: 'Jumeirah Royal Hotel', destinationId: dubaiDest.id, supplierId: supGrandStays.id,
      starRating: 5, address: 'Jumeirah Beach Road, Dubai', contactPhone: '+97141234567',
      contactEmail: 'reservations@jumeirahroyal.ae', checkInTime: '14:00', checkOutTime: '12:00',
    },
  })

  const hotelMarina = await prisma.hotel.create({
    data: {
      name: 'Marina Bay Suites', destinationId: dubaiDest.id, supplierId: supGrandStays.id,
      starRating: 4, address: 'Dubai Marina Walk, Dubai', contactPhone: '+97142345678',
      contactEmail: 'info@marinabaysuites.ae', checkInTime: '15:00', checkOutTime: '11:00',
    },
  })

  // Abu Dhabi hotels
  const hotelEmirates = await prisma.hotel.create({
    data: {
      name: 'Emirates Palace View', destinationId: abuDhabiDest.id, supplierId: supGrandStays.id,
      starRating: 5, address: 'Corniche Road West, Abu Dhabi', contactPhone: '+97121234567',
      contactEmail: 'stay@emiratespalaceview.ae', checkInTime: '14:00', checkOutTime: '12:00',
    },
  })

  const hotelCorniche = await prisma.hotel.create({
    data: {
      name: 'Corniche Grand', destinationId: abuDhabiDest.id, supplierId: supGrandStays.id,
      starRating: 4, address: 'Corniche Road East, Abu Dhabi', contactPhone: '+97122345678',
      contactEmail: 'info@cornichegrand.ae', checkInTime: '14:00', checkOutTime: '12:00',
    },
  })

  // Bali hotels
  const hotelUbud = await prisma.hotel.create({
    data: {
      name: 'Ubud Jungle Resort', destinationId: baliDest.id, supplierId: supTropicalExcursions.id,
      starRating: 4, address: 'Jl. Monkey Forest, Ubud, Bali', contactPhone: '+62361234567',
      contactEmail: 'reservations@ubudjungle.id', checkInTime: '14:00', checkOutTime: '11:00',
    },
  })

  const hotelSeminyak = await prisma.hotel.create({
    data: {
      name: 'Seminyak Beach Hotel', destinationId: baliDest.id, supplierId: supTropicalExcursions.id,
      starRating: 5, address: 'Jl. Kayu Aya, Seminyak, Bali', contactPhone: '+62362345678',
      contactEmail: 'info@seminyakbeach.id', checkInTime: '15:00', checkOutTime: '12:00',
    },
  })

  // Maldives hotel
  const hotelCoral = await prisma.hotel.create({
    data: {
      name: 'Coral Island Resort', destinationId: maldivesDest.id, supplierId: supParadiseResorts.id,
      starRating: 5, address: 'North Male Atoll, Maldives', contactPhone: '+9603001234',
      contactEmail: 'reservations@coralisland.mv', checkInTime: '14:00', checkOutTime: '12:00',
    },
  })

  // Bangkok hotel
  const hotelSukhumvit = await prisma.hotel.create({
    data: {
      name: 'Sukhumvit Grand Hotel', destinationId: bangkokDest.id, supplierId: supAsianHotels.id,
      starRating: 4, address: 'Sukhumvit Soi 11, Bangkok', contactPhone: '+6621234567',
      contactEmail: 'info@sukhumvitgrand.th', checkInTime: '14:00', checkOutTime: '12:00',
    },
  })

  const allHotels = [hotelJumeirah, hotelMarina, hotelEmirates, hotelCorniche, hotelUbud, hotelSeminyak, hotelCoral, hotelSukhumvit]
  console.log(`   ✓ ${allHotels.length} hotels created\n`)

  // ============================================================
  // PHASE 10: ROOM TYPES (2 per hotel)
  // ============================================================
  console.log('🛏️  Creating room types...')

  const roomTypes: Record<string, { standard: string; deluxe: string }> = {}

  for (const hotel of allHotels) {
    const standard = await prisma.roomType.create({
      data: {
        hotelId: hotel.id, name: 'Standard Room', maxOccupancy: 2,
        description: 'Comfortable room with modern amenities',
        amenities: 'WiFi, TV, Mini Bar, Air Conditioning',
      },
    })
    const deluxe = await prisma.roomType.create({
      data: {
        hotelId: hotel.id, name: 'Deluxe Suite', maxOccupancy: 3,
        description: 'Spacious suite with premium furnishings and views',
        amenities: 'WiFi, TV, Mini Bar, Balcony, Jacuzzi, Room Service',
      },
    })
    roomTypes[hotel.id] = { standard: standard.id, deluxe: deluxe.id }
  }

  console.log(`   ✓ ${allHotels.length * 2} room types created\n`)

  // ============================================================
  // PHASE 11: ROOM PRICING (Peak + Regular for each room type)
  // ============================================================
  console.log('💰 Creating room pricing...')

  // Price config: [hotel, standardSingle, standardDouble, deluxeSingle, deluxeDouble]
  const hotelPrices: Array<{ hotel: typeof hotelJumeirah; stdS: number; stdD: number; dlxS: number; dlxD: number }> = [
    { hotel: hotelJumeirah, stdS: 250, stdD: 300, dlxS: 450, dlxD: 520 },
    { hotel: hotelMarina, stdS: 180, stdD: 220, dlxS: 320, dlxD: 380 },
    { hotel: hotelEmirates, stdS: 280, stdD: 340, dlxS: 500, dlxD: 580 },
    { hotel: hotelCorniche, stdS: 160, stdD: 200, dlxS: 280, dlxD: 340 },
    { hotel: hotelUbud, stdS: 120, stdD: 150, dlxS: 220, dlxD: 270 },
    { hotel: hotelSeminyak, stdS: 200, stdD: 250, dlxS: 380, dlxD: 450 },
    { hotel: hotelCoral, stdS: 300, stdD: 380, dlxS: 550, dlxD: 650 },
    { hotel: hotelSukhumvit, stdS: 100, stdD: 130, dlxS: 200, dlxD: 260 },
  ]

  let pricingCount = 0
  for (const hp of hotelPrices) {
    const rt = roomTypes[hp.hotel.id]

    // Peak season: Dec 1 - Mar 31 (1.3x multiplier)
    await prisma.roomPricing.create({
      data: {
        roomTypeId: rt.standard, seasonName: 'Peak', startDate: new Date('2025-12-01'), endDate: new Date('2026-03-31'),
        mealPlan: 'CP', singleRate: Math.round(hp.stdS * 1.3), doubleRate: Math.round(hp.stdD * 1.3),
        extraBedRate: 50, childRate: 30, currency: 'USD',
      },
    })
    await prisma.roomPricing.create({
      data: {
        roomTypeId: rt.standard, seasonName: 'Regular', startDate: new Date('2026-04-01'), endDate: new Date('2026-11-30'),
        mealPlan: 'CP', singleRate: hp.stdS, doubleRate: hp.stdD,
        extraBedRate: 40, childRate: 25, currency: 'USD',
      },
    })
    await prisma.roomPricing.create({
      data: {
        roomTypeId: rt.deluxe, seasonName: 'Peak', startDate: new Date('2025-12-01'), endDate: new Date('2026-03-31'),
        mealPlan: 'MAP', singleRate: Math.round(hp.dlxS * 1.3), doubleRate: Math.round(hp.dlxD * 1.3),
        extraBedRate: 80, childRate: 50, currency: 'USD',
      },
    })
    await prisma.roomPricing.create({
      data: {
        roomTypeId: rt.deluxe, seasonName: 'Regular', startDate: new Date('2026-04-01'), endDate: new Date('2026-11-30'),
        mealPlan: 'MAP', singleRate: hp.dlxS, doubleRate: hp.dlxD,
        extraBedRate: 70, childRate: 40, currency: 'USD',
      },
    })
    pricingCount += 4
  }

  console.log(`   ✓ ${pricingCount} room pricing entries created\n`)

  // ============================================================
  // PHASE 12: TRANSPORT ROUTES
  // ============================================================
  console.log('🛣️  Creating transport routes...')

  const routeDubaiAirport = await prisma.transportRoute.create({
    data: { destinationId: dubaiDest.id, name: 'Dubai Airport to City Center', fromLocation: 'Dubai International Airport (DXB)', toLocation: 'Downtown Dubai', distanceKm: 25, durationMinutes: 30 },
  })

  const routeDubaiCityTour = await prisma.transportRoute.create({
    data: { destinationId: dubaiDest.id, name: 'Dubai City Tour', fromLocation: 'Hotel Pickup', toLocation: 'City Tour Circuit', distanceKm: 50, durationMinutes: 240 },
  })

  const routeAbuDhabiAirport = await prisma.transportRoute.create({
    data: { destinationId: abuDhabiDest.id, name: 'Abu Dhabi Airport to Hotel', fromLocation: 'Abu Dhabi International Airport (AUH)', toLocation: 'Corniche Area', distanceKm: 30, durationMinutes: 35 },
  })

  const routeBaliUbud = await prisma.transportRoute.create({
    data: { destinationId: baliDest.id, name: 'Bali Airport to Ubud', fromLocation: 'Ngurah Rai International Airport', toLocation: 'Ubud Center', distanceKm: 40, durationMinutes: 90 },
  })

  const routeBaliSeminyak = await prisma.transportRoute.create({
    data: { destinationId: baliDest.id, name: 'Bali Airport to Seminyak', fromLocation: 'Ngurah Rai International Airport', toLocation: 'Seminyak', distanceKm: 12, durationMinutes: 30 },
  })

  const routeBangkokAirport = await prisma.transportRoute.create({
    data: { destinationId: bangkokDest.id, name: 'Bangkok Airport to Sukhumvit', fromLocation: 'Suvarnabhumi Airport (BKK)', toLocation: 'Sukhumvit Area', distanceKm: 35, durationMinutes: 45 },
  })

  const allRoutes = [routeDubaiAirport, routeDubaiCityTour, routeAbuDhabiAirport, routeBaliUbud, routeBaliSeminyak, routeBangkokAirport]
  console.log(`   ✓ ${allRoutes.length} transport routes created\n`)

  // ============================================================
  // PHASE 13: TRANSPORT PRICING (2 per route: SEDAN + SUV)
  // ============================================================
  console.log('💲 Creating transport pricing...')

  const routePrices: Array<{ route: typeof routeDubaiAirport; sedanPrice: number; suvPrice: number }> = [
    { route: routeDubaiAirport, sedanPrice: 40, suvPrice: 65 },
    { route: routeDubaiCityTour, sedanPrice: 70, suvPrice: 110 },
    { route: routeAbuDhabiAirport, sedanPrice: 45, suvPrice: 70 },
    { route: routeBaliUbud, sedanPrice: 35, suvPrice: 55 },
    { route: routeBaliSeminyak, sedanPrice: 25, suvPrice: 40 },
    { route: routeBangkokAirport, sedanPrice: 30, suvPrice: 50 },
  ]

  let transportPricingCount = 0
  for (const rp of routePrices) {
    await prisma.transportPricing.create({
      data: {
        routeId: rp.route.id, vehicleType: 'SEDAN', seasonName: 'Year Round',
        startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'),
        pricePerTrip: rp.sedanPrice, currency: 'USD',
      },
    })
    await prisma.transportPricing.create({
      data: {
        routeId: rp.route.id, vehicleType: 'SUV', seasonName: 'Year Round',
        startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'),
        pricePerTrip: rp.suvPrice, currency: 'USD',
      },
    })
    transportPricingCount += 2
  }

  console.log(`   ✓ ${transportPricingCount} transport pricing entries created\n`)

  // ============================================================
  // PHASE 14: ACTIVITIES
  // ============================================================
  console.log('🎯 Creating activities...')

  // Dubai activities
  const actDesertSafari = await prisma.activity.create({
    data: {
      name: 'Desert Safari Adventure', destinationId: dubaiDest.id, supplierId: supAdventureWorld.id,
      type: 'ADVENTURE', description: 'Thrilling desert safari with dune bashing, camel riding, and BBQ dinner',
      durationMinutes: 360, maxCapacity: 30, minAge: 5,
    },
  })

  const actDhowCruise = await prisma.activity.create({
    data: {
      name: 'Dhow Cruise Dinner', destinationId: dubaiDest.id, supplierId: supAdventureWorld.id,
      type: 'CRUISE', description: 'Traditional dhow cruise along Dubai Creek with buffet dinner and entertainment',
      durationMinutes: 150, maxCapacity: 50,
    },
  })

  const actDubaiCityTour = await prisma.activity.create({
    data: {
      name: 'Dubai City Tour', destinationId: dubaiDest.id, supplierId: supAdventureWorld.id,
      type: 'SIGHTSEEING', description: 'Full-day guided city tour covering Burj Khalifa, Dubai Mall, Gold Souk, and Jumeirah Mosque',
      durationMinutes: 480, maxCapacity: 20,
    },
  })

  // Bali activities
  const actMonkeyForest = await prisma.activity.create({
    data: {
      name: 'Monkey Forest Tour', destinationId: baliDest.id, supplierId: supTropicalExcursions.id,
      type: 'NATURE', description: 'Guided walk through the Sacred Monkey Forest Sanctuary in Ubud',
      durationMinutes: 120, maxCapacity: 15,
    },
  })

  const actRiceTerrace = await prisma.activity.create({
    data: {
      name: 'Rice Terrace Trek', destinationId: baliDest.id, supplierId: supTropicalExcursions.id,
      type: 'TREKKING', description: 'Scenic trek through Tegallalang Rice Terraces with local guide',
      durationMinutes: 180, maxCapacity: 12, minAge: 8,
    },
  })

  // Bangkok activities
  const actTempleTour = await prisma.activity.create({
    data: {
      name: 'Temple Tour', destinationId: bangkokDest.id, supplierId: supAsianHotels.id,
      type: 'CULTURAL', description: 'Visit Wat Phra Kaew, Wat Pho, and Wat Arun with expert guide',
      durationMinutes: 300, maxCapacity: 20,
    },
  })

  const actFloatingMarket = await prisma.activity.create({
    data: {
      name: 'Floating Market Experience', destinationId: bangkokDest.id, supplierId: supAsianHotels.id,
      type: 'CULTURAL', description: 'Full-day trip to Damnoen Saduak Floating Market with boat ride',
      durationMinutes: 360, maxCapacity: 15, minAge: 5,
    },
  })

  // Maldives activity
  const actSnorkeling = await prisma.activity.create({
    data: {
      name: 'Snorkeling Trip', destinationId: maldivesDest.id, supplierId: supParadiseResorts.id,
      type: 'WATER_SPORT', description: 'Half-day snorkeling trip to pristine coral reefs with equipment included',
      durationMinutes: 240, maxCapacity: 10, minAge: 8,
    },
  })

  const allActivities = [actDesertSafari, actDhowCruise, actDubaiCityTour, actMonkeyForest, actRiceTerrace, actTempleTour, actFloatingMarket, actSnorkeling]
  console.log(`   ✓ ${allActivities.length} activities created\n`)

  // ============================================================
  // PHASE 15: ACTIVITY SLOTS
  // ============================================================
  console.log('🕐 Creating activity slots...')

  const activitySlotData: Array<{
    activityId: string; startTime: string; endTime: string; seasonName: string;
    startDate: Date; endDate: Date; adultPrice: number; childPrice: number;
  }> = [
    // Desert Safari - afternoon/evening
    { activityId: actDesertSafari.id, startTime: '15:00', endTime: '21:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 85, childPrice: 55 },
    // Dhow Cruise - evening
    { activityId: actDhowCruise.id, startTime: '19:00', endTime: '21:30', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 65, childPrice: 40 },
    // Dubai City Tour - morning
    { activityId: actDubaiCityTour.id, startTime: '08:00', endTime: '16:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 95, childPrice: 60 },
    // Monkey Forest - morning + afternoon
    { activityId: actMonkeyForest.id, startTime: '09:00', endTime: '11:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 35, childPrice: 20 },
    { activityId: actMonkeyForest.id, startTime: '14:00', endTime: '16:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 35, childPrice: 20 },
    // Rice Terrace Trek - morning
    { activityId: actRiceTerrace.id, startTime: '07:00', endTime: '10:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 45, childPrice: 30 },
    // Temple Tour - morning
    { activityId: actTempleTour.id, startTime: '08:00', endTime: '13:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 55, childPrice: 35 },
    // Floating Market - early morning
    { activityId: actFloatingMarket.id, startTime: '06:00', endTime: '12:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 70, childPrice: 45 },
    // Snorkeling - morning + afternoon
    { activityId: actSnorkeling.id, startTime: '09:00', endTime: '13:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 120, childPrice: 80 },
    { activityId: actSnorkeling.id, startTime: '14:00', endTime: '18:00', seasonName: 'Year Round', startDate: new Date('2025-01-01'), endDate: new Date('2026-12-31'), adultPrice: 120, childPrice: 80 },
  ]

  for (const slot of activitySlotData) {
    await prisma.activitySlot.create({ data: slot })
  }

  console.log(`   ✓ ${activitySlotData.length} activity slots created\n`)

  // ============================================================
  // PHASE 16: QUERIES (15 queries across different stages)
  // ============================================================
  console.log('📋 Creating queries...')

  const queryConfigs: Array<{
    queryNo: string; stage: 'NEW' | 'IN_PROGRESS' | 'QUOTED' | 'CONFIRMED' | 'COMPLETED';
    leadName: string; leadEmail: string; leadPhone: string;
    adults: number; children: number; infants: number;
    travelStartDate: Date; travelEndDate: Date; nights: number;
    budget: number; tripSourceId: string; assignedToId: string;
    destinationIds: string[]; destNights: number[];
    date: Date; specialRequests?: string;
  }> = [
    // 3 NEW
    {
      queryNo: 'QRY-0001', stage: 'NEW', leadName: 'James Wilson', leadEmail: 'james.wilson@email.com', leadPhone: '+14155551001',
      adults: 2, children: 1, infants: 0, travelStartDate: new Date('2026-04-10'), travelEndDate: new Date('2026-04-15'), nights: 5,
      budget: 5000, tripSourceId: tsTravelMax.id, assignedToId: salesUser.id,
      destinationIds: [dubaiDest.id], destNights: [5], date: new Date('2026-02-20'),
    },
    {
      queryNo: 'QRY-0002', stage: 'NEW', leadName: 'Emma Thompson', leadEmail: 'emma.t@email.com', leadPhone: '+44207551002',
      adults: 4, children: 2, infants: 0, travelStartDate: new Date('2026-05-01'), travelEndDate: new Date('2026-05-08'), nights: 7,
      budget: 12000, tripSourceId: tsWebsite.id, assignedToId: salesUser.id,
      destinationIds: [baliDest.id], destNights: [7], date: new Date('2026-02-22'),
    },
    {
      queryNo: 'QRY-0003', stage: 'NEW', leadName: 'Raj Patel', leadEmail: 'raj.patel@email.com', leadPhone: '+919876543210',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-06-15'), travelEndDate: new Date('2026-06-20'), nights: 5,
      budget: 8000, tripSourceId: tsInstagram.id, assignedToId: opsUser.id,
      destinationIds: [maldivesDest.id], destNights: [5], date: new Date('2026-02-25'),
      specialRequests: 'Honeymoon package with overwater villa preferred',
    },

    // 3 IN_PROGRESS
    {
      queryNo: 'QRY-0004', stage: 'IN_PROGRESS', leadName: 'Sophie Chen', leadEmail: 'sophie.chen@email.com', leadPhone: '+8613912345678',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-20'), travelEndDate: new Date('2026-03-27'), nights: 7,
      budget: 6000, tripSourceId: tsGlobeTrotters.id, assignedToId: salesUser.id,
      destinationIds: [bangkokDest.id, singaporeDest.id], destNights: [4, 3], date: new Date('2026-02-10'),
    },
    {
      queryNo: 'QRY-0005', stage: 'IN_PROGRESS', leadName: 'Michael Brown', leadEmail: 'michael.b@email.com', leadPhone: '+14155551005',
      adults: 6, children: 3, infants: 1, travelStartDate: new Date('2026-04-05'), travelEndDate: new Date('2026-04-12'), nights: 7,
      budget: 18000, tripSourceId: tsTravelMax.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id, abuDhabiDest.id], destNights: [4, 3], date: new Date('2026-02-05'),
      specialRequests: 'Large family trip, need connecting rooms',
    },
    {
      queryNo: 'QRY-0006', stage: 'IN_PROGRESS', leadName: 'Yuki Tanaka', leadEmail: 'yuki.t@email.com', leadPhone: '+81345678901',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-15'), travelEndDate: new Date('2026-03-22'), nights: 7,
      budget: 7000, tripSourceId: tsWalkIn.id, assignedToId: salesUser.id,
      destinationIds: [baliDest.id], destNights: [7], date: new Date('2026-01-28'),
    },

    // 3 QUOTED
    {
      queryNo: 'QRY-0007', stage: 'QUOTED', leadName: 'David Garcia', leadEmail: 'david.g@email.com', leadPhone: '+34612345678',
      adults: 2, children: 2, infants: 0, travelStartDate: new Date('2026-03-10'), travelEndDate: new Date('2026-03-15'), nights: 5,
      budget: 6000, tripSourceId: tsGlobeTrotters.id, assignedToId: salesUser.id,
      destinationIds: [dubaiDest.id], destNights: [5], date: new Date('2026-01-15'),
    },
    {
      queryNo: 'QRY-0008', stage: 'QUOTED', leadName: 'Lisa Anderson', leadEmail: 'lisa.a@email.com', leadPhone: '+14155551008',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-04-01'), travelEndDate: new Date('2026-04-06'), nights: 5,
      budget: 10000, tripSourceId: tsReferral.id, assignedToId: opsUser.id,
      destinationIds: [maldivesDest.id], destNights: [5], date: new Date('2026-01-20'),
      specialRequests: 'Anniversary trip, sunset dinner requested',
    },
    {
      queryNo: 'QRY-0009', stage: 'QUOTED', leadName: 'Hans Mueller', leadEmail: 'hans.m@email.com', leadPhone: '+49171234567',
      adults: 3, children: 1, infants: 0, travelStartDate: new Date('2026-03-25'), travelEndDate: new Date('2026-04-01'), nights: 7,
      budget: 9000, tripSourceId: tsTravelMax.id, assignedToId: salesUser.id,
      destinationIds: [bangkokDest.id, baliDest.id], destNights: [3, 4], date: new Date('2026-01-10'),
    },

    // 4 CONFIRMED
    {
      queryNo: 'QRY-0010', stage: 'CONFIRMED', leadName: 'Robert Johnson', leadEmail: 'robert.j@email.com', leadPhone: '+14155551010',
      adults: 2, children: 1, infants: 0, travelStartDate: new Date('2025-10-01'), travelEndDate: new Date('2025-10-05'), nights: 4,
      budget: 5500, tripSourceId: tsTravelMax.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id], destNights: [4], date: new Date('2025-08-15'),
    },
    {
      queryNo: 'QRY-0011', stage: 'CONFIRMED', leadName: 'Maria Santos', leadEmail: 'maria.s@email.com', leadPhone: '+5511987654321',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2025-11-15'), travelEndDate: new Date('2025-11-20'), nights: 5,
      budget: 8000, tripSourceId: tsWebsite.id, assignedToId: salesUser.id,
      destinationIds: [maldivesDest.id], destNights: [5], date: new Date('2025-09-20'),
    },
    {
      queryNo: 'QRY-0012', stage: 'CONFIRMED', leadName: 'Ahmed Al Farsi', leadEmail: 'ahmed.f@email.com', leadPhone: '+968912345678',
      adults: 4, children: 2, infants: 1, travelStartDate: new Date('2025-12-20'), travelEndDate: new Date('2025-12-27'), nights: 7,
      budget: 15000, tripSourceId: tsGlobeTrotters.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id, abuDhabiDest.id], destNights: [4, 3], date: new Date('2025-10-10'),
    },
    {
      queryNo: 'QRY-0013', stage: 'CONFIRMED', leadName: 'Chen Wei', leadEmail: 'chen.w@email.com', leadPhone: '+8613987654321',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-01-10'), travelEndDate: new Date('2026-01-17'), nights: 7,
      budget: 7500, tripSourceId: tsInstagram.id, assignedToId: salesUser.id,
      destinationIds: [baliDest.id], destNights: [7], date: new Date('2025-11-05'),
    },

    // 2 COMPLETED
    {
      queryNo: 'QRY-0014', stage: 'COMPLETED', leadName: 'John Davis', leadEmail: 'john.d@email.com', leadPhone: '+14155551014',
      adults: 2, children: 2, infants: 0, travelStartDate: new Date('2025-09-01'), travelEndDate: new Date('2025-09-06'), nights: 5,
      budget: 6000, tripSourceId: tsTravelMax.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id], destNights: [5], date: new Date('2025-07-15'),
    },
    {
      queryNo: 'QRY-0015', stage: 'COMPLETED', leadName: 'Aisha Khoury', leadEmail: 'aisha.k@email.com', leadPhone: '+9611234567',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2025-08-10'), travelEndDate: new Date('2025-08-17'), nights: 7,
      budget: 9000, tripSourceId: tsReferral.id, assignedToId: salesUser.id,
      destinationIds: [bangkokDest.id, baliDest.id], destNights: [3, 4], date: new Date('2025-06-20'),
    },
  ]

  const queryMap: Record<string, string> = {} // queryNo -> queryId

  for (const qc of queryConfigs) {
    const query = await prisma.query.create({
      data: {
        queryNo: qc.queryNo,
        date: qc.date,
        stage: qc.stage,
        leadName: qc.leadName,
        leadEmail: qc.leadEmail,
        leadPhone: qc.leadPhone,
        adults: qc.adults,
        children: qc.children,
        infants: qc.infants,
        travelStartDate: qc.travelStartDate,
        travelEndDate: qc.travelEndDate,
        nights: qc.nights,
        budget: qc.budget,
        budgetCurrency: 'USD',
        specialRequests: qc.specialRequests,
        tripSourceId: qc.tripSourceId,
        assignedToId: qc.assignedToId,
        createdById: admin.id,
      },
    })
    queryMap[qc.queryNo] = query.id

    // Create QueryDestination links
    for (let i = 0; i < qc.destinationIds.length; i++) {
      await prisma.queryDestination.create({
        data: {
          queryId: query.id,
          destinationId: qc.destinationIds[i],
          nights: qc.destNights[i],
          sortOrder: i,
        },
      })
    }
  }

  console.log(`   ✓ ${queryConfigs.length} queries created with destination links\n`)

  // ============================================================
  // PHASE 17: QUOTES (6 for QUOTED + CONFIRMED queries)
  // ============================================================
  console.log('📝 Creating quotes...')

  const quoteConfigs: Array<{
    quoteNo: string; queryNo: string; isSelected: boolean;
    items: Array<{ serviceType: 'HOTEL' | 'TRANSPORT' | 'ACTIVITY' | 'VISA' | 'INSURANCE' | 'GUIDE' | 'OTHER'; description: string; dayNumber: number; quantity: number; unitCost: number }>
  }> = [
    {
      quoteNo: 'QOT-0001', queryNo: 'QRY-0007', isSelected: false,
      items: [
        { serviceType: 'HOTEL', description: 'Jumeirah Royal Hotel - Standard Room (5 nights)', dayNumber: 1, quantity: 5, unitCost: 250 },
        { serviceType: 'TRANSPORT', description: 'Airport pickup - Sedan', dayNumber: 1, quantity: 1, unitCost: 40 },
        { serviceType: 'TRANSPORT', description: 'Airport drop - Sedan', dayNumber: 5, quantity: 1, unitCost: 40 },
        { serviceType: 'ACTIVITY', description: 'Desert Safari Adventure', dayNumber: 2, quantity: 4, unitCost: 85 },
        { serviceType: 'ACTIVITY', description: 'Dhow Cruise Dinner', dayNumber: 4, quantity: 4, unitCost: 65 },
      ],
    },
    {
      quoteNo: 'QOT-0002', queryNo: 'QRY-0008', isSelected: false,
      items: [
        { serviceType: 'HOTEL', description: 'Coral Island Resort - Deluxe Suite (5 nights)', dayNumber: 1, quantity: 5, unitCost: 550 },
        { serviceType: 'TRANSPORT', description: 'Speedboat transfer - Airport to Resort', dayNumber: 1, quantity: 2, unitCost: 150 },
        { serviceType: 'TRANSPORT', description: 'Speedboat transfer - Resort to Airport', dayNumber: 5, quantity: 2, unitCost: 150 },
        { serviceType: 'ACTIVITY', description: 'Snorkeling Trip', dayNumber: 3, quantity: 2, unitCost: 120 },
      ],
    },
    {
      quoteNo: 'QOT-0003', queryNo: 'QRY-0009', isSelected: false,
      items: [
        { serviceType: 'HOTEL', description: 'Sukhumvit Grand Hotel - Standard Room (3 nights)', dayNumber: 1, quantity: 3, unitCost: 100 },
        { serviceType: 'HOTEL', description: 'Ubud Jungle Resort - Standard Room (4 nights)', dayNumber: 4, quantity: 4, unitCost: 120 },
        { serviceType: 'TRANSPORT', description: 'Bangkok Airport transfer', dayNumber: 1, quantity: 1, unitCost: 30 },
        { serviceType: 'ACTIVITY', description: 'Temple Tour', dayNumber: 2, quantity: 4, unitCost: 55 },
        { serviceType: 'ACTIVITY', description: 'Rice Terrace Trek', dayNumber: 5, quantity: 4, unitCost: 45 },
      ],
    },
    {
      quoteNo: 'QOT-0004', queryNo: 'QRY-0010', isSelected: true,
      items: [
        { serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room (4 nights)', dayNumber: 1, quantity: 4, unitCost: 180 },
        { serviceType: 'TRANSPORT', description: 'Airport pickup - SUV', dayNumber: 1, quantity: 1, unitCost: 65 },
        { serviceType: 'TRANSPORT', description: 'Airport drop - SUV', dayNumber: 4, quantity: 1, unitCost: 65 },
        { serviceType: 'ACTIVITY', description: 'Desert Safari Adventure', dayNumber: 2, quantity: 3, unitCost: 85 },
        { serviceType: 'ACTIVITY', description: 'Dubai City Tour', dayNumber: 3, quantity: 3, unitCost: 95 },
      ],
    },
    {
      quoteNo: 'QOT-0005', queryNo: 'QRY-0011', isSelected: true,
      items: [
        { serviceType: 'HOTEL', description: 'Coral Island Resort - Standard Room (5 nights)', dayNumber: 1, quantity: 5, unitCost: 300 },
        { serviceType: 'TRANSPORT', description: 'Speedboat transfer to Resort', dayNumber: 1, quantity: 2, unitCost: 150 },
        { serviceType: 'TRANSPORT', description: 'Speedboat transfer to Airport', dayNumber: 5, quantity: 2, unitCost: 150 },
        { serviceType: 'ACTIVITY', description: 'Snorkeling Trip', dayNumber: 2, quantity: 2, unitCost: 120 },
        { serviceType: 'ACTIVITY', description: 'Snorkeling Trip - Afternoon', dayNumber: 4, quantity: 2, unitCost: 120 },
      ],
    },
    {
      quoteNo: 'QOT-0006', queryNo: 'QRY-0012', isSelected: true,
      items: [
        { serviceType: 'HOTEL', description: 'Jumeirah Royal Hotel - Deluxe Suite (4 nights)', dayNumber: 1, quantity: 4, unitCost: 450 },
        { serviceType: 'HOTEL', description: 'Emirates Palace View - Deluxe Suite (3 nights)', dayNumber: 5, quantity: 3, unitCost: 500 },
        { serviceType: 'TRANSPORT', description: 'Airport pickup - Minibus', dayNumber: 1, quantity: 1, unitCost: 80 },
        { serviceType: 'TRANSPORT', description: 'Dubai to Abu Dhabi transfer', dayNumber: 5, quantity: 1, unitCost: 120 },
        { serviceType: 'ACTIVITY', description: 'Desert Safari (family)', dayNumber: 2, quantity: 6, unitCost: 85 },
        { serviceType: 'ACTIVITY', description: 'Dhow Cruise Dinner (family)', dayNumber: 3, quantity: 6, unitCost: 65 },
      ],
    },
  ]

  const quoteMap: Record<string, string> = {} // quoteNo -> quoteId

  for (const qc of quoteConfigs) {
    const subtotal = qc.items.reduce((sum, item) => sum + (item.quantity * item.unitCost), 0)
    const markupPercent = 15
    const markup = Math.round(subtotal * markupPercent / 100)
    const taxPercent = 5
    const taxAmount = Math.round((subtotal + markup) * taxPercent / 100)
    const totalAmount = subtotal + markup + taxAmount

    const quote = await prisma.quote.create({
      data: {
        quoteNo: qc.quoteNo,
        queryId: queryMap[qc.queryNo],
        version: 1,
        date: new Date(),
        validUntil: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // +30 days
        subtotal,
        markup,
        markupPercent,
        taxAmount,
        taxPercent,
        totalAmount,
        currency: 'USD',
        isSelected: qc.isSelected,
        createdById: admin.id,
        notes: qc.isSelected ? 'Client approved this quote' : undefined,
      },
    })
    quoteMap[qc.quoteNo] = quote.id

    // Create quote items
    for (let i = 0; i < qc.items.length; i++) {
      const item = qc.items[i]
      await prisma.quoteItem.create({
        data: {
          quoteId: quote.id,
          serviceType: item.serviceType,
          description: item.description,
          dayNumber: item.dayNumber,
          quantity: item.quantity,
          unitCost: item.unitCost,
          totalCost: item.quantity * item.unitCost,
          sortOrder: i,
        },
      })
    }
  }

  console.log(`   ✓ ${quoteConfigs.length} quotes with items created\n`)

  // ============================================================
  // PHASE 18: BOOKINGS (5 for CONFIRMED queries)
  // ============================================================
  console.log('📅 Creating bookings...')

  const bookingConfigs: Array<{
    bookingNo: string; queryNo: string; status: 'CONFIRMED' | 'IN_PROGRESS' | 'COMPLETED';
    startDate: Date; endDate: Date; totalAmount: number;
    leadName: string;
  }> = [
    { bookingNo: 'BKG-0001', queryNo: 'QRY-0010', status: 'COMPLETED', startDate: new Date('2025-10-01'), endDate: new Date('2025-10-05'), totalAmount: 5200, leadName: 'Robert Johnson' },
    { bookingNo: 'BKG-0002', queryNo: 'QRY-0011', status: 'COMPLETED', startDate: new Date('2025-11-15'), endDate: new Date('2025-11-20'), totalAmount: 8500, leadName: 'Maria Santos' },
    { bookingNo: 'BKG-0003', queryNo: 'QRY-0012', status: 'CONFIRMED', startDate: new Date('2025-12-20'), endDate: new Date('2025-12-27'), totalAmount: 11500, leadName: 'Ahmed Al Farsi' },
    { bookingNo: 'BKG-0004', queryNo: 'QRY-0013', status: 'IN_PROGRESS', startDate: new Date('2026-01-10'), endDate: new Date('2026-01-17'), totalAmount: 6800, leadName: 'Chen Wei' },
    { bookingNo: 'BKG-0005', queryNo: 'QRY-0014', status: 'COMPLETED', startDate: new Date('2025-09-01'), endDate: new Date('2025-09-06'), totalAmount: 4200, leadName: 'John Davis' },
  ]

  const bookingMap: Record<string, { id: string; startDate: Date; leadName: string }> = {}

  for (const bc of bookingConfigs) {
    const booking = await prisma.booking.create({
      data: {
        bookingNo: bc.bookingNo,
        queryId: queryMap[bc.queryNo],
        status: bc.status,
        startDate: bc.startDate,
        endDate: bc.endDate,
        totalAmount: bc.totalAmount,
        paidAmount: 0, // updated after payments
        currency: 'USD',
        createdById: admin.id,
      },
    })
    bookingMap[bc.bookingNo] = { id: booking.id, startDate: bc.startDate, leadName: bc.leadName }
  }

  console.log(`   ✓ ${bookingConfigs.length} bookings created\n`)

  // ============================================================
  // PHASE 19: ITINERARY DAYS (3 per booking)
  // ============================================================
  console.log('📄 Creating itinerary days...')

  const itineraryDayMap: Record<string, string[]> = {} // bookingNo -> [dayId, dayId, dayId]

  for (const bc of bookingConfigs) {
    const bk = bookingMap[bc.bookingNo]
    const days: string[] = []

    for (let dayNum = 1; dayNum <= 3; dayNum++) {
      const dayDate = new Date(bk.startDate)
      dayDate.setDate(dayDate.getDate() + dayNum - 1)

      let title = ''
      if (dayNum === 1) title = 'Arrival & Check-in'
      else if (dayNum === 2) title = 'Sightseeing & Activities'
      else if (dayNum === 3) title = 'Excursion Day'

      const day = await prisma.itineraryDay.create({
        data: {
          bookingId: bk.id,
          dayNumber: dayNum,
          date: dayDate,
          title,
          description: `Day ${dayNum} itinerary for ${bc.leadName}`,
          sortOrder: dayNum - 1,
        },
      })
      days.push(day.id)
    }
    itineraryDayMap[bc.bookingNo] = days
  }

  console.log(`   ✓ ${bookingConfigs.length * 3} itinerary days created\n`)

  // ============================================================
  // PHASE 20: BOOKING ITEMS (2-3 per day)
  // ============================================================
  console.log('📦 Creating booking items...')

  let bookingItemCount = 0

  // Helper to create booking items for each booking
  const bookingItemSets: Record<string, Array<{
    dayIndex: number; serviceType: 'HOTEL' | 'TRANSPORT' | 'ACTIVITY';
    description: string; startTime?: string; endTime?: string;
    quantity: number; unitCost: number;
    hotelId?: string; activityId?: string;
  }>> = {
    'BKG-0001': [
      // Day 1
      { dayIndex: 0, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', startTime: '14:00', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 0, serviceType: 'TRANSPORT', description: 'Airport pickup - SUV', startTime: '12:00', endTime: '13:00', quantity: 1, unitCost: 65 },
      // Day 2
      { dayIndex: 1, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Desert Safari Adventure', startTime: '15:00', endTime: '21:00', quantity: 3, unitCost: 85, activityId: actDesertSafari.id },
      // Day 3
      { dayIndex: 2, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 2, serviceType: 'ACTIVITY', description: 'Dubai City Tour', startTime: '08:00', endTime: '16:00', quantity: 3, unitCost: 95, activityId: actDubaiCityTour.id },
      { dayIndex: 2, serviceType: 'TRANSPORT', description: 'City tour transport - Sedan', startTime: '08:00', endTime: '16:00', quantity: 1, unitCost: 70 },
    ],
    'BKG-0002': [
      { dayIndex: 0, serviceType: 'HOTEL', description: 'Coral Island Resort - Standard Room', startTime: '14:00', quantity: 1, unitCost: 300, hotelId: hotelCoral.id },
      { dayIndex: 0, serviceType: 'TRANSPORT', description: 'Speedboat transfer to Resort', startTime: '11:00', endTime: '12:30', quantity: 2, unitCost: 150 },
      { dayIndex: 1, serviceType: 'HOTEL', description: 'Coral Island Resort - Standard Room', quantity: 1, unitCost: 300, hotelId: hotelCoral.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Snorkeling Trip - Morning', startTime: '09:00', endTime: '13:00', quantity: 2, unitCost: 120, activityId: actSnorkeling.id },
      { dayIndex: 2, serviceType: 'HOTEL', description: 'Coral Island Resort - Standard Room', quantity: 1, unitCost: 300, hotelId: hotelCoral.id },
      { dayIndex: 2, serviceType: 'ACTIVITY', description: 'Snorkeling Trip - Afternoon', startTime: '14:00', endTime: '18:00', quantity: 2, unitCost: 120, activityId: actSnorkeling.id },
    ],
    'BKG-0003': [
      { dayIndex: 0, serviceType: 'HOTEL', description: 'Jumeirah Royal Hotel - Deluxe Suite', startTime: '14:00', quantity: 1, unitCost: 450, hotelId: hotelJumeirah.id },
      { dayIndex: 0, serviceType: 'TRANSPORT', description: 'Airport pickup - Minibus', startTime: '10:00', endTime: '11:00', quantity: 1, unitCost: 80 },
      { dayIndex: 1, serviceType: 'HOTEL', description: 'Jumeirah Royal Hotel - Deluxe Suite', quantity: 1, unitCost: 450, hotelId: hotelJumeirah.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Desert Safari (family)', startTime: '15:00', endTime: '21:00', quantity: 6, unitCost: 85, activityId: actDesertSafari.id },
      { dayIndex: 2, serviceType: 'HOTEL', description: 'Jumeirah Royal Hotel - Deluxe Suite', quantity: 1, unitCost: 450, hotelId: hotelJumeirah.id },
      { dayIndex: 2, serviceType: 'ACTIVITY', description: 'Dhow Cruise Dinner (family)', startTime: '19:00', endTime: '21:30', quantity: 6, unitCost: 65, activityId: actDhowCruise.id },
    ],
    'BKG-0004': [
      { dayIndex: 0, serviceType: 'HOTEL', description: 'Ubud Jungle Resort - Standard Room', startTime: '14:00', quantity: 1, unitCost: 120, hotelId: hotelUbud.id },
      { dayIndex: 0, serviceType: 'TRANSPORT', description: 'Airport to Ubud transfer', startTime: '10:00', endTime: '11:30', quantity: 1, unitCost: 35 },
      { dayIndex: 1, serviceType: 'HOTEL', description: 'Ubud Jungle Resort - Standard Room', quantity: 1, unitCost: 120, hotelId: hotelUbud.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Monkey Forest Tour', startTime: '09:00', endTime: '11:00', quantity: 2, unitCost: 35, activityId: actMonkeyForest.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Rice Terrace Trek', startTime: '14:00', endTime: '17:00', quantity: 2, unitCost: 45, activityId: actRiceTerrace.id },
      { dayIndex: 2, serviceType: 'HOTEL', description: 'Ubud Jungle Resort - Standard Room', quantity: 1, unitCost: 120, hotelId: hotelUbud.id },
      { dayIndex: 2, serviceType: 'TRANSPORT', description: 'Day trip transport', startTime: '08:00', endTime: '18:00', quantity: 1, unitCost: 55 },
    ],
    'BKG-0005': [
      { dayIndex: 0, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', startTime: '14:00', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 0, serviceType: 'TRANSPORT', description: 'Airport pickup - SUV', startTime: '09:00', endTime: '10:00', quantity: 1, unitCost: 65 },
      { dayIndex: 1, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 1, serviceType: 'ACTIVITY', description: 'Desert Safari Adventure', startTime: '15:00', endTime: '21:00', quantity: 4, unitCost: 85, activityId: actDesertSafari.id },
      { dayIndex: 2, serviceType: 'HOTEL', description: 'Marina Bay Suites - Standard Room', quantity: 1, unitCost: 180, hotelId: hotelMarina.id },
      { dayIndex: 2, serviceType: 'TRANSPORT', description: 'Airport drop - SUV', startTime: '10:00', endTime: '11:00', quantity: 1, unitCost: 65 },
    ],
  }

  for (const bookingNo of Object.keys(bookingItemSets)) {
    const bk = bookingMap[bookingNo]
    const days = itineraryDayMap[bookingNo]
    const items = bookingItemSets[bookingNo]

    for (let i = 0; i < items.length; i++) {
      const item = items[i]
      await prisma.bookingItem.create({
        data: {
          bookingId: bk.id,
          itineraryDayId: days[item.dayIndex],
          serviceType: item.serviceType,
          description: item.description,
          startTime: item.startTime,
          endTime: item.endTime,
          hotelId: item.hotelId,
          activityId: item.activityId,
          quantity: item.quantity,
          unitCost: item.unitCost,
          totalCost: item.quantity * item.unitCost,
          sortOrder: i,
        },
      })
      bookingItemCount++
    }
  }

  console.log(`   ✓ ${bookingItemCount} booking items created\n`)

  // ============================================================
  // PHASE 18B: ADDITIONAL BOOKINGS FOR OPERATIONS
  // 10 new queries (QRY-0016 to QRY-0025) with CONFIRMED stage
  // + corresponding bookings (BKG-0006 to BKG-0015) for travel
  // dates that include 2026-03-03
  // ============================================================
  console.log('📋 Creating additional queries & bookings for daily operations...')

  const additionalQueryConfigs: Array<{
    queryNo: string; leadName: string; leadEmail: string; leadPhone: string;
    adults: number; children: number; infants: number;
    travelStartDate: Date; travelEndDate: Date; nights: number;
    budget: number; tripSourceId: string; assignedToId: string;
    destinationIds: string[]; destNights: number[];
    date: Date; specialRequests?: string;
  }> = [
    {
      queryNo: 'QRY-0016', leadName: 'David Garcia', leadEmail: 'david.garcia@email.com', leadPhone: '+34612345001',
      adults: 4, children: 0, infants: 0, travelStartDate: new Date('2026-03-01'), travelEndDate: new Date('2026-03-06'), nights: 5,
      budget: 7000, tripSourceId: tsGlobeTrotters.id, assignedToId: salesUser.id,
      destinationIds: [dubaiDest.id], destNights: [5], date: new Date('2026-02-10'),
      specialRequests: 'Family holiday, need spacious rooms',
    },
    {
      queryNo: 'QRY-0017', leadName: 'Lisa Anderson', leadEmail: 'lisa.anderson@email.com', leadPhone: '+14155552001',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-02'), travelEndDate: new Date('2026-03-07'), nights: 5,
      budget: 5000, tripSourceId: tsReferral.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id], destNights: [5], date: new Date('2026-02-12'),
    },
    {
      queryNo: 'QRY-0018', leadName: 'James Wilson', leadEmail: 'james.wilson2@email.com', leadPhone: '+14155553001',
      adults: 2, children: 2, infants: 0, travelStartDate: new Date('2026-03-03'), travelEndDate: new Date('2026-03-07'), nights: 4,
      budget: 6000, tripSourceId: tsTravelMax.id, assignedToId: salesUser.id,
      destinationIds: [dubaiDest.id], destNights: [4], date: new Date('2026-02-15'),
      specialRequests: 'Arriving early morning, need early check-in',
    },
    {
      queryNo: 'QRY-0019', leadName: 'Sarah Kim', leadEmail: 'sarah.kim@email.com', leadPhone: '+82101234567',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-02'), travelEndDate: new Date('2026-03-05'), nights: 3,
      budget: 4000, tripSourceId: tsWebsite.id, assignedToId: salesUser.id,
      destinationIds: [abuDhabiDest.id], destNights: [3], date: new Date('2026-02-14'),
    },
    {
      queryNo: 'QRY-0020', leadName: 'Michael Brown', leadEmail: 'michael.brown2@email.com', leadPhone: '+14155554001',
      adults: 6, children: 3, infants: 0, travelStartDate: new Date('2026-03-01'), travelEndDate: new Date('2026-03-06'), nights: 5,
      budget: 18000, tripSourceId: tsTravelMax.id, assignedToId: opsUser.id,
      destinationIds: [abuDhabiDest.id], destNights: [5], date: new Date('2026-02-05'),
      specialRequests: 'Large family group, need 3 connecting rooms and minibus transfers',
    },
    {
      queryNo: 'QRY-0021', leadName: 'Emily Chen', leadEmail: 'emily.chen@email.com', leadPhone: '+8613800138001',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-01'), travelEndDate: new Date('2026-03-08'), nights: 7,
      budget: 5500, tripSourceId: tsInstagram.id, assignedToId: salesUser.id,
      destinationIds: [baliDest.id], destNights: [7], date: new Date('2026-02-08'),
      specialRequests: 'Honeymoon trip, want rice terrace and temple visits',
    },
    {
      queryNo: 'QRY-0022', leadName: 'Tom Harris', leadEmail: 'tom.harris@email.com', leadPhone: '+44207553001',
      adults: 3, children: 0, infants: 0, travelStartDate: new Date('2026-03-02'), travelEndDate: new Date('2026-03-07'), nights: 5,
      budget: 4500, tripSourceId: tsWalkIn.id, assignedToId: opsUser.id,
      destinationIds: [baliDest.id], destNights: [5], date: new Date('2026-02-11'),
    },
    {
      queryNo: 'QRY-0023', leadName: 'Aisha Khoury', leadEmail: 'aisha.khoury2@email.com', leadPhone: '+9611234568',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-03'), travelEndDate: new Date('2026-03-07'), nights: 4,
      budget: 5000, tripSourceId: tsReferral.id, assignedToId: salesUser.id,
      destinationIds: [dubaiDest.id], destNights: [4], date: new Date('2026-02-18'),
    },
    {
      queryNo: 'QRY-0024', leadName: 'Hans Mueller', leadEmail: 'hans.mueller2@email.com', leadPhone: '+49171234568',
      adults: 3, children: 1, infants: 0, travelStartDate: new Date('2026-03-01'), travelEndDate: new Date('2026-03-07'), nights: 6,
      budget: 12000, tripSourceId: tsGlobeTrotters.id, assignedToId: opsUser.id,
      destinationIds: [dubaiDest.id, abuDhabiDest.id], destNights: [3, 3], date: new Date('2026-02-02'),
      specialRequests: 'Multi-city: 3 nights Dubai, 3 nights Abu Dhabi',
    },
    {
      queryNo: 'QRY-0025', leadName: 'Yuki Tanaka', leadEmail: 'yuki.tanaka2@email.com', leadPhone: '+81345678902',
      adults: 2, children: 0, infants: 0, travelStartDate: new Date('2026-03-03'), travelEndDate: new Date('2026-03-08'), nights: 5,
      budget: 4000, tripSourceId: tsWebsite.id, assignedToId: salesUser.id,
      destinationIds: [baliDest.id], destNights: [5], date: new Date('2026-02-20'),
    },
  ]

  for (const qc of additionalQueryConfigs) {
    const query = await prisma.query.create({
      data: {
        queryNo: qc.queryNo,
        date: qc.date,
        stage: 'CONFIRMED',
        leadName: qc.leadName,
        leadEmail: qc.leadEmail,
        leadPhone: qc.leadPhone,
        adults: qc.adults,
        children: qc.children,
        infants: qc.infants,
        travelStartDate: qc.travelStartDate,
        travelEndDate: qc.travelEndDate,
        nights: qc.nights,
        budget: qc.budget,
        budgetCurrency: 'USD',
        specialRequests: qc.specialRequests,
        tripSourceId: qc.tripSourceId,
        assignedToId: qc.assignedToId,
        createdById: admin.id,
      },
    })
    queryMap[qc.queryNo] = query.id

    for (let i = 0; i < qc.destinationIds.length; i++) {
      await prisma.queryDestination.create({
        data: {
          queryId: query.id,
          destinationId: qc.destinationIds[i],
          nights: qc.destNights[i],
          sortOrder: i,
        },
      })
    }
  }

  // Create bookings for the additional queries
  const additionalBookingConfigs: Array<{
    bookingNo: string; queryNo: string; status: 'CONFIRMED' | 'IN_PROGRESS';
    startDate: Date; endDate: Date; totalAmount: number; leadName: string;
  }> = [
    { bookingNo: 'BKG-0006', queryNo: 'QRY-0016', status: 'CONFIRMED', startDate: new Date('2026-03-01'), endDate: new Date('2026-03-06'), totalAmount: 6800, leadName: 'David Garcia' },
    { bookingNo: 'BKG-0007', queryNo: 'QRY-0017', status: 'CONFIRMED', startDate: new Date('2026-03-02'), endDate: new Date('2026-03-07'), totalAmount: 4800, leadName: 'Lisa Anderson' },
    { bookingNo: 'BKG-0008', queryNo: 'QRY-0018', status: 'CONFIRMED', startDate: new Date('2026-03-03'), endDate: new Date('2026-03-07'), totalAmount: 5500, leadName: 'James Wilson' },
    { bookingNo: 'BKG-0009', queryNo: 'QRY-0019', status: 'CONFIRMED', startDate: new Date('2026-03-02'), endDate: new Date('2026-03-05'), totalAmount: 3800, leadName: 'Sarah Kim' },
    { bookingNo: 'BKG-0010', queryNo: 'QRY-0020', status: 'CONFIRMED', startDate: new Date('2026-03-01'), endDate: new Date('2026-03-06'), totalAmount: 16500, leadName: 'Michael Brown' },
    { bookingNo: 'BKG-0011', queryNo: 'QRY-0021', status: 'CONFIRMED', startDate: new Date('2026-03-01'), endDate: new Date('2026-03-08'), totalAmount: 5200, leadName: 'Emily Chen' },
    { bookingNo: 'BKG-0012', queryNo: 'QRY-0022', status: 'CONFIRMED', startDate: new Date('2026-03-02'), endDate: new Date('2026-03-07'), totalAmount: 4200, leadName: 'Tom Harris' },
    { bookingNo: 'BKG-0013', queryNo: 'QRY-0023', status: 'CONFIRMED', startDate: new Date('2026-03-03'), endDate: new Date('2026-03-07'), totalAmount: 4800, leadName: 'Aisha Khoury' },
    { bookingNo: 'BKG-0014', queryNo: 'QRY-0024', status: 'CONFIRMED', startDate: new Date('2026-03-01'), endDate: new Date('2026-03-07'), totalAmount: 11200, leadName: 'Hans Mueller' },
    { bookingNo: 'BKG-0015', queryNo: 'QRY-0025', status: 'CONFIRMED', startDate: new Date('2026-03-03'), endDate: new Date('2026-03-08'), totalAmount: 3800, leadName: 'Yuki Tanaka' },
  ]

  for (const bc of additionalBookingConfigs) {
    const booking = await prisma.booking.create({
      data: {
        bookingNo: bc.bookingNo,
        queryId: queryMap[bc.queryNo],
        status: bc.status,
        startDate: bc.startDate,
        endDate: bc.endDate,
        totalAmount: bc.totalAmount,
        paidAmount: 0,
        currency: 'USD',
        createdById: admin.id,
      },
    })
    bookingMap[bc.bookingNo] = { id: booking.id, startDate: bc.startDate, leadName: bc.leadName }
  }

  console.log(`   ✓ ${additionalQueryConfigs.length} additional queries + ${additionalBookingConfigs.length} additional bookings created\n`)

  // ============================================================
  // PHASE 21: PAYMENTS (12 - CRITICAL for revenue charts)
  // Spread across last 6 months for monthly revenue data
  // ============================================================
  console.log('💳 Creating payments...')

  const paymentConfigs: Array<{
    paymentNo: string; bookingNo: string; amount: number;
    paymentDate: Date; status: 'COMPLETED' | 'PARTIAL' | 'PENDING';
    method: string;
  }> = [
    // September 2025 payments
    { paymentNo: 'PAY-0001', bookingNo: 'BKG-0005', amount: 2000, paymentDate: new Date('2025-09-05'), status: 'COMPLETED', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0002', bookingNo: 'BKG-0005', amount: 2200, paymentDate: new Date('2025-09-15'), status: 'COMPLETED', method: 'CREDIT_CARD' },

    // October 2025 payments
    { paymentNo: 'PAY-0003', bookingNo: 'BKG-0001', amount: 2500, paymentDate: new Date('2025-10-02'), status: 'COMPLETED', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0004', bookingNo: 'BKG-0001', amount: 2700, paymentDate: new Date('2025-10-20'), status: 'COMPLETED', method: 'CREDIT_CARD' },

    // November 2025 payments
    { paymentNo: 'PAY-0005', bookingNo: 'BKG-0002', amount: 3000, paymentDate: new Date('2025-11-10'), status: 'COMPLETED', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0006', bookingNo: 'BKG-0002', amount: 2500, paymentDate: new Date('2025-11-25'), status: 'PARTIAL', method: 'CREDIT_CARD' },

    // December 2025 payments
    { paymentNo: 'PAY-0007', bookingNo: 'BKG-0003', amount: 5000, paymentDate: new Date('2025-12-01'), status: 'COMPLETED', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0008', bookingNo: 'BKG-0003', amount: 3500, paymentDate: new Date('2025-12-15'), status: 'PARTIAL', method: 'CASH' },

    // January 2026 payments
    { paymentNo: 'PAY-0009', bookingNo: 'BKG-0004', amount: 2000, paymentDate: new Date('2026-01-05'), status: 'PARTIAL', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0010', bookingNo: 'BKG-0004', amount: 1500, paymentDate: new Date('2026-01-20'), status: 'PENDING', method: 'CREDIT_CARD' },

    // February 2026 payments
    { paymentNo: 'PAY-0011', bookingNo: 'BKG-0003', amount: 1500, paymentDate: new Date('2026-02-10'), status: 'PENDING', method: 'BANK_TRANSFER' },
    { paymentNo: 'PAY-0012', bookingNo: 'BKG-0004', amount: 1000, paymentDate: new Date('2026-02-20'), status: 'PENDING', method: 'CASH' },
  ]

  // Track paid amounts per booking for updating
  const paidPerBooking: Record<string, number> = {}

  for (const pc of paymentConfigs) {
    const bk = bookingMap[pc.bookingNo]
    await prisma.payment.create({
      data: {
        paymentNo: pc.paymentNo,
        bookingId: bk.id,
        amount: pc.amount,
        currency: 'USD',
        paymentDate: pc.paymentDate,
        method: pc.method,
        status: pc.status,
        referenceNo: `REF-${pc.paymentNo.replace('PAY-', '')}`,
        notes: pc.status === 'COMPLETED' ? 'Payment received and verified' : undefined,
      },
    })

    // Track completed/partial payments for paidAmount
    if (pc.status === 'COMPLETED' || pc.status === 'PARTIAL') {
      paidPerBooking[pc.bookingNo] = (paidPerBooking[pc.bookingNo] || 0) + pc.amount
    }
  }

  // Update booking paidAmount
  for (const [bookingNo, paidAmount] of Object.entries(paidPerBooking)) {
    const bk = bookingMap[bookingNo]
    await prisma.booking.update({
      where: { id: bk.id },
      data: { paidAmount },
    })
  }

  console.log(`   ✓ ${paymentConfigs.length} payments created (spread across 6 months)\n`)

  // ============================================================
  // PHASE 22: FUND ALLOCATIONS (6)
  // ============================================================
  console.log('🏦 Creating fund allocations...')

  const fundConfigs: Array<{
    bookingNo: string; supplierId: string; amount: number;
    status: 'BLOCKED' | 'RELEASED' | 'PAID';
    allocatedDate: Date; releasedDate?: Date; paidDate?: Date;
  }> = [
    // BKG-0001 allocations
    { bookingNo: 'BKG-0001', supplierId: supGrandStays.id, amount: 720, status: 'PAID', allocatedDate: new Date('2025-09-25'), releasedDate: new Date('2025-10-03'), paidDate: new Date('2025-10-10') },
    { bookingNo: 'BKG-0001', supplierId: supAdventureWorld.id, amount: 510, status: 'PAID', allocatedDate: new Date('2025-09-25'), releasedDate: new Date('2025-10-03'), paidDate: new Date('2025-10-10') },

    // BKG-0002 allocations
    { bookingNo: 'BKG-0002', supplierId: supParadiseResorts.id, amount: 1500, status: 'RELEASED', allocatedDate: new Date('2025-11-01'), releasedDate: new Date('2025-11-18') },
    { bookingNo: 'BKG-0003', supplierId: supGrandStays.id, amount: 1800, status: 'RELEASED', allocatedDate: new Date('2025-12-10'), releasedDate: new Date('2025-12-22') },

    // BKG-0004 allocations
    { bookingNo: 'BKG-0004', supplierId: supTropicalExcursions.id, amount: 600, status: 'BLOCKED', allocatedDate: new Date('2026-01-05') },
    { bookingNo: 'BKG-0004', supplierId: supIslandShuttles.id, amount: 500, status: 'BLOCKED', allocatedDate: new Date('2026-01-05') },
  ]

  for (const fc of fundConfigs) {
    const bk = bookingMap[fc.bookingNo]
    await prisma.fundAllocation.create({
      data: {
        bookingId: bk.id,
        supplierId: fc.supplierId,
        amount: fc.amount,
        currency: 'USD',
        status: fc.status,
        allocatedDate: fc.allocatedDate,
        releasedDate: fc.releasedDate,
        paidDate: fc.paidDate,
        referenceNo: fc.paidDate ? `FA-${Date.now().toString(36).slice(-6).toUpperCase()}` : undefined,
      },
    })
  }

  console.log(`   ✓ ${fundConfigs.length} fund allocations created\n`)

  // ============================================================
  // PHASE 23: DAILY OPERATIONS (historical + 70+ for today)
  // Uses fromLocation/toLocation, vehicleType, paxCount
  // ============================================================
  console.log('🚐 Creating daily operations...')

  const opsConfigs: Array<{
    bookingNo: string; date: Date;
    operationType: 'PICKUP' | 'DROP' | 'TRANSFER' | 'SIGHTSEEING' | 'CHECKIN' | 'CHECKOUT' | 'ACTIVITY';
    title: string; startTime: string; endTime?: string;
    fromLocation: string; toLocation: string;
    driverId: string; driverName: string; driverPhone: string;
    vehicleNo: string; vehicleType: string; paxCount: number;
    adultCount?: number; childCount?: number; returnTime?: string;
    supplierName?: string; supplierPhone?: string; supplier2Name?: string;
    sellingPrice?: number; ticketCost?: number; costPrice1?: number; costPrice2?: number;
    agentName?: string; bookingPerson?: string; country?: string;
    status: string;
  }> = [
    // ========== HISTORICAL OPERATIONS (converted to fromLocation/toLocation) ==========

    // BKG-0001 operations (Oct 2025, Dubai)
    {
      bookingNo: 'BKG-0001', date: new Date('2025-10-01'), operationType: 'PICKUP',
      title: 'Airport Pickup - Robert Johnson', startTime: '12:00', endTime: '13:00',
      fromLocation: 'DXB Terminal 3', toLocation: 'Marina Bay Suites',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 3,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0001', date: new Date('2025-10-02'), operationType: 'ACTIVITY',
      title: 'Desert Safari Pickup', startTime: '14:30', endTime: '15:00',
      fromLocation: 'Marina Bay Suites', toLocation: 'Desert Safari Camp',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 3,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0001', date: new Date('2025-10-03'), operationType: 'SIGHTSEEING',
      title: 'Dubai City Tour', startTime: '08:00', endTime: '16:00',
      fromLocation: 'Marina Bay Suites', toLocation: 'Dubai City Tour Circuit',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 3,
      status: 'COMPLETED',
    },

    // BKG-0003 operations (Dec 2025, Dubai + Abu Dhabi)
    {
      bookingNo: 'BKG-0003', date: new Date('2025-12-20'), operationType: 'PICKUP',
      title: 'Airport Pickup - Al Farsi Family', startTime: '10:00', endTime: '11:00',
      fromLocation: 'DXB Terminal 1', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 7,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0003', date: new Date('2025-12-24'), operationType: 'TRANSFER',
      title: 'Dubai to Abu Dhabi Transfer', startTime: '09:00', endTime: '11:00',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Emirates Palace View',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 7,
      status: 'COMPLETED',
    },

    // BKG-0004 operations (Jan 2026, Bali)
    {
      bookingNo: 'BKG-0004', date: new Date('2026-01-10'), operationType: 'PICKUP',
      title: 'Airport Pickup - Chen Wei', startTime: '10:00', endTime: '11:30',
      fromLocation: 'Ngurah Rai Airport', toLocation: 'Ubud Jungle Resort',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0004', date: new Date('2026-01-11'), operationType: 'ACTIVITY',
      title: 'Monkey Forest Tour Transport', startTime: '08:30', endTime: '12:00',
      fromLocation: 'Ubud Jungle Resort', toLocation: 'Monkey Forest Sanctuary',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0004', date: new Date('2026-01-12'), operationType: 'SIGHTSEEING',
      title: 'Full Day Bali Tour', startTime: '08:00', endTime: '18:00',
      fromLocation: 'Ubud Jungle Resort', toLocation: 'Kintamani Volcano Viewpoint',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },

    // BKG-0005 operations (Sep 2025, Dubai)
    {
      bookingNo: 'BKG-0005', date: new Date('2025-09-01'), operationType: 'PICKUP',
      title: 'Airport Pickup - John Davis', startTime: '09:00', endTime: '10:00',
      fromLocation: 'DXB Terminal 3', toLocation: 'Marina Bay Suites',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0005', date: new Date('2025-09-05'), operationType: 'DROP',
      title: 'Airport Drop - John Davis', startTime: '10:00', endTime: '11:00',
      fromLocation: 'Marina Bay Suites', toLocation: 'DXB Terminal 3',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 4,
      status: 'COMPLETED',
    },

    // ========== TODAY 2026-03-03: 70+ OPERATIONS ==========
    // Driver allocation:
    //   Ahmed Al Rashid: Dubai, Sedan DXB-A-11234, ~12 ops
    //   Mohammed Saeed: Dubai, SUV DXB-B-55678, ~12 ops
    //   Khalid Noor: Abu Dhabi, Van AUH-C-22345, ~10 ops
    //   Rashid Abdullah: Abu Dhabi, Minibus AUH-D-33456, ~10 ops
    //   Made Wayan: Bali, Sedan BA-1234-XY, ~10 ops
    //   Ketut Dharma: Bali, Van BA-5678-ZZ, ~10 ops
    //
    // Status rules: before 10AM = COMPLETED, 10-12 = IN_PROGRESS, after 12 = SCHEDULED
    // 4 deliberate conflicts included (same driver, overlapping times)

    // ────────────────────────────────────────────────────────────
    // AHMED AL RASHID — Dubai, Sedan DXB-A-11234 (12 ops)
    // ────────────────────────────────────────────────────────────

    // CONFLICT: Ahmed 05:30-06:30 (BKG-0006) overlaps with 05:30-07:00 (BKG-0008)
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'PICKUP',
      title: 'Airport Pickup - James Wilson Family', startTime: '05:30', endTime: '07:00',
      fromLocation: 'DXB Terminal 3', toLocation: 'Marina Bay Suites',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0006', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Dubai Mall', startTime: '05:30', endTime: '06:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'DXB Terminal 3',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0006', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Dubai Mall', startTime: '08:30', endTime: '09:00',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Dubai Mall',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Burj Khalifa', startTime: '09:00', endTime: '09:30',
      fromLocation: 'Marina Bay Suites', toLocation: 'Burj Khalifa',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Burj Khalifa to Dubai Mall', startTime: '11:30', endTime: '11:45',
      fromLocation: 'Burj Khalifa', toLocation: 'Dubai Mall',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0006', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Mall to Hotel', startTime: '14:00', endTime: '14:30',
      fromLocation: 'Dubai Mall', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Mall to Hotel', startTime: '15:00', endTime: '15:30',
      fromLocation: 'Dubai Mall', toLocation: 'Marina Bay Suites',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0006', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Dubai Creek Wharf', startTime: '18:30', endTime: '19:00',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Dubai Creek Wharf',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0006', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Creek Wharf to Hotel', startTime: '21:30', endTime: '22:00',
      fromLocation: 'Dubai Creek Wharf', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'PICKUP',
      title: 'Airport Pickup - Aisha Khoury', startTime: '06:00', endTime: '06:45',
      fromLocation: 'DXB Terminal 1', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to JBR Beach', startTime: '16:30', endTime: '17:00',
      fromLocation: 'Marina Bay Suites', toLocation: 'JBR Beach',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0008', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'JBR Beach to Hotel', startTime: '19:30', endTime: '20:00',
      fromLocation: 'JBR Beach', toLocation: 'Marina Bay Suites',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 4,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // MOHAMMED SAEED — Dubai, SUV DXB-B-55678 (12 ops)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Gold Souk', startTime: '07:30', endTime: '08:00',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Gold Souk',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Gold Souk to Dubai Frame', startTime: '09:30', endTime: '09:50',
      fromLocation: 'Gold Souk', toLocation: 'Dubai Frame',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'COMPLETED',
    },
    // CONFLICT: Mohammed 10:00-11:30 (BKG-0007) overlaps with 10:00-11:00 (BKG-0013)
    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Frame to La Mer Beach', startTime: '10:00', endTime: '11:30',
      fromLocation: 'Dubai Frame', toLocation: 'La Mer Beach',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Dubai Mall', startTime: '10:00', endTime: '11:00',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Dubai Mall',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'La Mer Beach to Hotel', startTime: '13:00', endTime: '13:30',
      fromLocation: 'La Mer Beach', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Mall to Burj Khalifa', startTime: '13:30', endTime: '13:45',
      fromLocation: 'Dubai Mall', toLocation: 'Burj Khalifa',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Burj Khalifa to Hotel', startTime: '16:00', endTime: '16:30',
      fromLocation: 'Burj Khalifa', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Dubai Mall', startTime: '08:00', endTime: '08:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Dubai Mall',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Mall to Palm Jumeirah', startTime: '12:00', endTime: '12:30',
      fromLocation: 'Dubai Mall', toLocation: 'Palm Jumeirah',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Palm Jumeirah to Hotel', startTime: '15:30', endTime: '16:00',
      fromLocation: 'Palm Jumeirah', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Dhow Cruise Terminal', startTime: '18:00', endTime: '18:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Dhow Cruise Terminal',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0007', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dhow Cruise Terminal to Hotel', startTime: '21:00', endTime: '21:30',
      fromLocation: 'Dhow Cruise Terminal', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // KHALID NOOR — Abu Dhabi, Van AUH-C-22345 (10 ops)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Sheikh Zayed Mosque', startTime: '07:00', endTime: '07:30',
      fromLocation: 'Saadiyat Beach Resort', toLocation: 'Sheikh Zayed Grand Mosque',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Mosque to Louvre Abu Dhabi', startTime: '09:00', endTime: '09:20',
      fromLocation: 'Sheikh Zayed Grand Mosque', toLocation: 'Louvre Abu Dhabi',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Louvre to Corniche', startTime: '11:30', endTime: '12:00',
      fromLocation: 'Louvre Abu Dhabi', toLocation: 'Abu Dhabi Corniche',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'IN_PROGRESS',
    },
    // CONFLICT: Khalid 14:00-15:30 (BKG-0009) overlaps with 14:00-15:00 (BKG-0010)
    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Corniche to Hotel', startTime: '14:00', endTime: '15:30',
      fromLocation: 'Abu Dhabi Corniche', toLocation: 'Saadiyat Beach Resort',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Mangrove Park', startTime: '14:00', endTime: '15:00',
      fromLocation: 'Emirates Palace View', toLocation: 'Mangrove National Park',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Sheikh Zayed Mosque', startTime: '07:30', endTime: '08:00',
      fromLocation: 'Emirates Palace View', toLocation: 'Sheikh Zayed Grand Mosque',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 9,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Mosque to Yas Island', startTime: '10:00', endTime: '10:30',
      fromLocation: 'Sheikh Zayed Grand Mosque', toLocation: 'Yas Island',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 9,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Mangrove Park to Hotel', startTime: '17:00', endTime: '17:30',
      fromLocation: 'Mangrove National Park', toLocation: 'Emirates Palace View',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Yas Marina Dinner', startTime: '19:00', endTime: '19:30',
      fromLocation: 'Saadiyat Beach Resort', toLocation: 'Yas Marina',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0009', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Yas Marina to Hotel', startTime: '22:00', endTime: '22:30',
      fromLocation: 'Yas Marina', toLocation: 'Saadiyat Beach Resort',
      driverId: driverKhalid.id, driverName: 'Khalid Noor', driverPhone: '+971503334455',
      vehicleNo: 'AUH-C-22345', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // RASHID ABDULLAH — Abu Dhabi, Minibus AUH-D-33456 (10 ops)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Yas Island to Ferrari World', startTime: '11:00', endTime: '11:15',
      fromLocation: 'Yas Island', toLocation: 'Ferrari World',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Ferrari World to Hotel for Lunch', startTime: '13:00', endTime: '13:30',
      fromLocation: 'Ferrari World', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Corniche Beach', startTime: '15:30', endTime: '16:00',
      fromLocation: 'Emirates Palace View', toLocation: 'Abu Dhabi Corniche Beach',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Corniche Beach to Hotel', startTime: '18:00', endTime: '18:20',
      fromLocation: 'Abu Dhabi Corniche Beach', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Dinner at Emirates Palace', startTime: '19:30', endTime: '20:00',
      fromLocation: 'Emirates Palace View', toLocation: 'Emirates Palace Hotel Restaurant',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0010', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dinner Return to Hotel', startTime: '22:00', endTime: '22:15',
      fromLocation: 'Emirates Palace Hotel Restaurant', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 9,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dubai Hotel to Abu Dhabi Hotel', startTime: '06:00', endTime: '07:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Louvre Abu Dhabi', startTime: '09:00', endTime: '09:20',
      fromLocation: 'Emirates Palace View', toLocation: 'Louvre Abu Dhabi',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Louvre to Sheikh Zayed Mosque', startTime: '12:00', endTime: '12:30',
      fromLocation: 'Louvre Abu Dhabi', toLocation: 'Sheikh Zayed Grand Mosque',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Mosque to Hotel', startTime: '14:30', endTime: '15:00',
      fromLocation: 'Sheikh Zayed Grand Mosque', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // MADE WAYAN — Bali, Sedan BA-1234-XY (10 ops)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'PICKUP',
      title: 'Airport Pickup - Yuki Tanaka', startTime: '05:00', endTime: '06:30',
      fromLocation: 'Ngurah Rai Airport', toLocation: 'Seminyak Beach Hotel',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Tegallalang Rice Terraces', startTime: '07:00', endTime: '08:00',
      fromLocation: 'Ubud Jungle Resort', toLocation: 'Tegallalang Rice Terraces',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    // CONFLICT: Made 09:00-10:30 (BKG-0011) overlaps with 09:00-10:00 (BKG-0012)
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Rice Terraces to Monkey Forest', startTime: '09:00', endTime: '10:30',
      fromLocation: 'Tegallalang Rice Terraces', toLocation: 'Monkey Forest Sanctuary',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Tanah Lot Temple', startTime: '09:00', endTime: '10:00',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Tanah Lot Temple',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 3,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Monkey Forest to Hotel', startTime: '12:00', endTime: '12:30',
      fromLocation: 'Monkey Forest Sanctuary', toLocation: 'Ubud Jungle Resort',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Bali Safari Park', startTime: '14:00', endTime: '14:45',
      fromLocation: 'Ubud Jungle Resort', toLocation: 'Bali Safari & Marine Park',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Safari Park to Hotel', startTime: '17:30', endTime: '18:15',
      fromLocation: 'Bali Safari & Marine Park', toLocation: 'Ubud Jungle Resort',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Uluwatu Temple', startTime: '15:00', endTime: '16:00',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Uluwatu Temple',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Uluwatu Temple to Hotel', startTime: '19:00', endTime: '20:00',
      fromLocation: 'Uluwatu Temple', toLocation: 'Seminyak Beach Hotel',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Seminyak Beach Dinner', startTime: '20:30', endTime: '20:45',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'La Lucciola Beach Restaurant',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // KETUT DHARMA — Bali, Van BA-5678-ZZ (10 ops)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Tanah Lot to Waterbom Park', startTime: '11:00', endTime: '11:45',
      fromLocation: 'Tanah Lot Temple', toLocation: 'Waterbom Bali',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Waterbom to Hotel for Lunch', startTime: '13:30', endTime: '14:00',
      fromLocation: 'Waterbom Bali', toLocation: 'Seminyak Beach Hotel',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Kintamani Volcano', startTime: '15:00', endTime: '16:30',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Kintamani Volcano Viewpoint',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Kintamani to Hotel', startTime: '18:00', endTime: '19:30',
      fromLocation: 'Kintamani Volcano Viewpoint', toLocation: 'Seminyak Beach Hotel',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Ubud Art Market', startTime: '08:00', endTime: '09:00',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Ubud Art Market',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Ubud Art Market to Tegallalang', startTime: '10:00', endTime: '10:20',
      fromLocation: 'Ubud Art Market', toLocation: 'Tegallalang Rice Terraces',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'IN_PROGRESS',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Tegallalang to Hotel', startTime: '12:30', endTime: '13:30',
      fromLocation: 'Tegallalang Rice Terraces', toLocation: 'Seminyak Beach Hotel',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Kecak Fire Dance', startTime: '18:30', endTime: '19:00',
      fromLocation: 'Ubud Jungle Resort', toLocation: 'Uluwatu Kecak Dance Amphitheater',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Kecak Dance to Jimbaran Dinner', startTime: '20:00', endTime: '20:30',
      fromLocation: 'Uluwatu Kecak Dance Amphitheater', toLocation: 'Jimbaran Bay Seafood',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0011', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Jimbaran Dinner to Hotel', startTime: '22:00', endTime: '23:00',
      fromLocation: 'Jimbaran Bay Seafood', toLocation: 'Ubud Jungle Resort',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 2,
      status: 'SCHEDULED',
    },

    // ────────────────────────────────────────────────────────────
    // ADDITIONAL OPS to reach 70+ for today
    // More stops for BKG-0013 (Aisha) and BKG-0014 (Hans)
    // ────────────────────────────────────────────────────────────

    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Hotel to Palm Jumeirah Beach', startTime: '07:00', endTime: '07:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Palm Jumeirah Beach',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Palm Jumeirah to Hotel', startTime: '09:00', endTime: '09:30',
      fromLocation: 'Palm Jumeirah Beach', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverAhmed.id, driverName: 'Ahmed Al Rashid', driverPhone: '+971501112233',
      vehicleNo: 'DXB-A-11234', vehicleType: 'SEDAN', paxCount: 2,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Desert Safari', startTime: '15:00', endTime: '15:30',
      fromLocation: 'Jumeirah Royal Hotel', toLocation: 'Desert Safari Camp',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0013', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Desert Safari to Hotel', startTime: '21:00', endTime: '22:00',
      fromLocation: 'Desert Safari Camp', toLocation: 'Jumeirah Royal Hotel',
      driverId: driverMohammed.id, driverName: 'Mohammed Saeed', driverPhone: '+971502223344',
      vehicleNo: 'DXB-B-55678', vehicleType: 'SUV', paxCount: 2,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Mangrove Kayaking', startTime: '16:00', endTime: '16:30',
      fromLocation: 'Emirates Palace View', toLocation: 'Mangrove National Park',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Mangrove to Hotel', startTime: '18:30', endTime: '19:00',
      fromLocation: 'Mangrove National Park', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Corniche Dinner', startTime: '20:00', endTime: '20:15',
      fromLocation: 'Emirates Palace View', toLocation: 'Abu Dhabi Corniche Promenade',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0014', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Corniche to Hotel', startTime: '22:30', endTime: '22:45',
      fromLocation: 'Abu Dhabi Corniche Promenade', toLocation: 'Emirates Palace View',
      driverId: driverRashid.id, driverName: 'Rashid Abdullah', driverPhone: '+971504445566',
      vehicleNo: 'AUH-D-33456', vehicleType: 'MINIBUS', paxCount: 4,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Spa & Wellness', startTime: '07:00', endTime: '07:15',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Seminyak Spa Retreat',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Spa to Hotel', startTime: '08:30', endTime: '08:45',
      fromLocation: 'Seminyak Spa Retreat', toLocation: 'Seminyak Beach Hotel',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'COMPLETED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'ACTIVITY',
      title: 'Hotel to Beach Club', startTime: '20:00', endTime: '20:15',
      fromLocation: 'Seminyak Beach Hotel', toLocation: 'Potato Head Beach Club',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0012', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Beach Club to Hotel', startTime: '23:00', endTime: '23:15',
      fromLocation: 'Potato Head Beach Club', toLocation: 'Seminyak Beach Hotel',
      driverId: driverKetut.id, driverName: 'Ketut Dharma', driverPhone: '+6281234567891',
      vehicleNo: 'BA-5678-ZZ', vehicleType: 'VAN', paxCount: 3,
      status: 'SCHEDULED',
    },
    {
      bookingNo: 'BKG-0015', date: new Date('2026-03-03'), operationType: 'TRANSFER',
      title: 'Dinner Restaurant to Hotel', startTime: '22:30', endTime: '22:45',
      fromLocation: 'La Lucciola Beach Restaurant', toLocation: 'Seminyak Beach Hotel',
      driverId: driverMade.id, driverName: 'Made Wayan', driverPhone: '+6281234567890',
      vehicleNo: 'BA-1234-XY', vehicleType: 'SEDAN', paxCount: 2,
      status: 'SCHEDULED',
    },
  ]

  for (const oc of opsConfigs) {
    const bk = bookingMap[oc.bookingNo]
    await prisma.dailyOperation.create({
      data: {
        bookingId: bk.id,
        date: oc.date,
        operationType: oc.operationType,
        title: oc.title,
        startTime: oc.startTime,
        endTime: oc.endTime,
        fromLocation: oc.fromLocation,
        toLocation: oc.toLocation,
        driverId: oc.driverId,
        driverName: oc.driverName,
        driverPhone: oc.driverPhone,
        vehicleNo: oc.vehicleNo,
        vehicleType: oc.vehicleType,
        paxCount: oc.paxCount,
        adultCount: oc.adultCount ?? null,
        childCount: oc.childCount ?? null,
        returnTime: oc.returnTime ?? null,
        supplierName: oc.supplierName ?? null,
        supplierPhone: oc.supplierPhone ?? null,
        supplier2Name: oc.supplier2Name ?? null,
        sellingPrice: oc.sellingPrice ?? null,
        ticketCost: oc.ticketCost ?? null,
        costPrice1: oc.costPrice1 ?? null,
        costPrice2: oc.costPrice2 ?? null,
        agentName: oc.agentName ?? null,
        bookingPerson: oc.bookingPerson ?? null,
        country: oc.country ?? null,
        guestName: bk.leadName,
        status: oc.status,
      },
    })
  }

  const todayOpsCount = opsConfigs.filter(o => o.date.toISOString().startsWith('2026-03-03')).length
  console.log(`   ✓ ${opsConfigs.length} daily operations created (${todayOpsCount} for today 2026-03-03)\n`)

  // ============================================================
  // PHASE 24: NOTIFICATIONS (5 for admin)
  // ============================================================
  console.log('🔔 Creating notifications...')

  const notificationConfigs = [
    { title: 'New Query Received', message: 'New query received from TravelMax Agency - James Wilson (QRY-0001)', type: 'INFO', module: 'queries', link: '/dmcify/queries' },
    { title: 'Payment Received', message: 'Payment of $2,500 received for BKG-0001 via bank transfer', type: 'SUCCESS', module: 'payments', link: '/dmcify/payments' },
    { title: 'Booking Starting Soon', message: 'Booking BKG-0003 for Ahmed Al Farsi starts tomorrow', type: 'WARNING', module: 'bookings', link: '/dmcify/bookings' },
    { title: 'Quote Approved', message: 'Quote QOT-0002 has been approved by the client - Lisa Anderson', type: 'SUCCESS', module: 'quotes', link: '/dmcify/quotes' },
    { title: 'License Expiring', message: 'Driver license expiring soon: Ahmed Al Rashid (DXB-12345) - expires Jun 2026', type: 'WARNING', module: 'operations', link: '/dmcify/operations' },
  ]

  for (const nc of notificationConfigs) {
    await prisma.notification.create({
      data: {
        userId: admin.id,
        title: nc.title,
        message: nc.message,
        type: nc.type,
        module: nc.module,
        link: nc.link,
      },
    })
  }

  console.log(`   ✓ ${notificationConfigs.length} notifications created\n`)

  // ============================================================
  // PHASE 25: COMPANY SETTINGS
  // ============================================================
  console.log('⚙️  Creating company settings...')

  await prisma.companySettings.upsert({
    where: { id: 'default' },
    update: {
      companyName: 'Dmcify Travel Solutions',
      defaultCurrency: 'USD',
      timezone: 'Asia/Dubai',
      fiscalYearStart: '04',
      email: 'info@dmcify.com',
      phone: '+971 4 123 4567',
      address: 'Business Bay, Dubai, UAE',
    },
    create: {
      id: 'default',
      companyName: 'Dmcify Travel Solutions',
      defaultCurrency: 'USD',
      timezone: 'Asia/Dubai',
      fiscalYearStart: '04',
      email: 'info@dmcify.com',
      phone: '+971 4 123 4567',
      address: 'Business Bay, Dubai, UAE',
    },
  })

  console.log('   ✓ Company settings created\n')

  // ============================================================
  // SUMMARY
  // ============================================================
  console.log('=' .repeat(60))
  console.log('✅ Database seeded successfully!')
  console.log('=' .repeat(60))
  console.log('')
  console.log('  Users:              4')
  console.log('  Destinations:       6')
  console.log('  Trip Sources:       6')
  console.log('  Number Series:      5')
  console.log('  Suppliers:          8')
  console.log('  Drivers:            6')
  console.log('  Vehicles:           6')
  console.log(`  Hotels:             ${allHotels.length}`)
  console.log(`  Room Types:         ${allHotels.length * 2}`)
  console.log(`  Room Pricing:       ${pricingCount}`)
  console.log(`  Transport Routes:   ${allRoutes.length}`)
  console.log(`  Transport Pricing:  ${transportPricingCount}`)
  console.log(`  Activities:         ${allActivities.length}`)
  console.log(`  Activity Slots:     ${activitySlotData.length}`)
  console.log(`  Queries:            ${queryConfigs.length + additionalQueryConfigs.length}`)
  console.log(`  Quotes:             ${quoteConfigs.length}`)
  console.log(`  Bookings:           ${bookingConfigs.length + additionalBookingConfigs.length}`)
  console.log(`  Itinerary Days:     ${bookingConfigs.length * 3}`)
  console.log(`  Booking Items:      ${bookingItemCount}`)
  console.log(`  Payments:           ${paymentConfigs.length}`)
  console.log(`  Fund Allocations:   ${fundConfigs.length}`)
  console.log(`  Daily Operations:   ${opsConfigs.length} (${todayOpsCount} for today)`)
  console.log(`  Notifications:      ${notificationConfigs.length}`)
  console.log('  Company Settings:   1')
  console.log('')
  console.log('  Login credentials:')
  console.log('  admin@dmcify.com    / admin123 (ADMIN)')
  console.log('  ops@dmcify.com      / admin123 (OPERATIONS)')
  console.log('  sales@dmcify.com    / admin123 (SALES)')
  console.log('  finance@dmcify.com  / admin123 (FINANCE)')
  console.log('')
}

main()
  .catch((e) => {
    console.error('Seed failed:', e)
    process.exit(1)
  })
  .finally(async () => {
    await prisma.$disconnect()
  })
