export type CarplaceLanguage = 'en' | 'fr' | 'ar'

export type AvailabilityStatus = 'AVAILABLE' | 'RESERVED' | 'MAINTENANCE' | 'UNAVAILABLE'

export interface CompanyBrand {
  displayName: string
  logoUrl: string | null
  subdomain: string
  publicCity?: string | null
  publicCountry?: string | null
  publicPhone?: string | null
  whatsappNumber?: string | null
  carplaceRating?: number | null
  primaryColor?: string | null
  description?: string | null
  coverImageUrl?: string | null
}

export interface VehicleSummary {
  id: string
  make: string
  model: string
  year: number
  category: string
  dailyRate: number
  photos: string[]
  seats?: number | null
  transmission?: string | null
  fuelType?: string | null
  pickupLocations: string[]
  allowDifferentDropoff: boolean
  dropoffLocations: string[]
  availability?: boolean | null
  availabilityStatus?: AvailabilityStatus
  nextAvailableAt?: string | null
  company: {
    slug: string
    brand: CompanyBrand | null
  }
}

export interface VehicleSearchResponse {
  items: VehicleSummary[]
  pagination: {
    page: number
    pageSize: number
    totalItems: number
    totalPages: number
  }
  facets: {
    categories: Array<{ value: string; count: number }>
    transmissions: Array<{ value: string; count: number }>
    makes: Array<{ value: string; count: number }>
    price: { min: number | null; max: number | null }
  }
}

export interface OfferSummary {
  id: string
  title: string
  type: 'PERCENTAGE' | 'FIXED_AMOUNT' | 'FREE_DAY' | 'SPECIAL_RATE'
  specialRate?: number | null
  description?: string | null
  discountValue: number
  validUntil: string
  promoCode?: string | null
  company: {
    slug?: string
    brand: CompanyBrand | null
  }
}

export interface CompanySummary {
  id: string
  slug?: string
  name?: string
  brand: CompanyBrand | null
  _count: { vehicles: number }
}

export interface CarplaceHomeResponse {
  cities: string[]
  offers: OfferSummary[]
  vehicles: VehicleSummary[]
  companies: CompanySummary[]
}

export interface QuoteResponse {
  available: boolean
  availabilityStatus: AvailabilityStatus
  nextAvailableAt: string | null
  currency: 'MAD'
  rentalDays: number
  dailyRate: number
  baseSubtotal: number
  discounts: Array<{ label: string; amount: number }>
  fees: Array<{ label: string; amount: number }>
  taxes: Array<{ label: string; amount: number }>
  estimatedTotal: number
  securityDeposit: number | null
  finalPriceRequiresCompanyConfirmation: true
}

export interface ReservationResult {
  reservationId: string
  bookingReference: string | null
  companyName: string
  vehicleName: string
  startDate: string
  endDate: string
  status: 'PENDING'
  message: string
}
