/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 */

export type PropertyType = 'charging' | 'parking' | 'both';

export interface Location {
  lat: number;
  lng: number;
  address: string;
  city: string;
}

export interface Review {
  id: string;
  bookingId: string;
  propertyId: string;
  userEmail: string;
  userName: string;
  rating: number; // 1-5 stars
  comment: string;
  createdAt: string;
}

export interface Property {
  id: string;
  title: string;
  type: PropertyType;
  photo: string;
  fare: number; // Fare in Rupees per hour
  rating: number;
  totalSlots: number;
  availableSlots: number;
  location: Location;
  description: string;
  amenities: string[];
  chargerTypes?: string[]; // e.g. ["CCS2 (Fast)", "Type 2", "GB/T"]
  hasPowerBackup: boolean;
  ownerId?: string; // Links to registered Property Owner ID
  isApproved: boolean; // Managed by Master Admin with unique pass
  reviews?: Review[];
}

export interface Booking {
  id: string;
  propertyId: string;
  propertyTitle: string;
  propertyType: PropertyType;
  userEmail: string;
  userName: string;
  vehicleNumber: string;
  vehicleType: 'Car' | 'Two-Wheeler';
  bookingDate: string; // YYYY-MM-DD
  timeSlot: string; // e.g. "10:00 AM - 11:00 AM"
  totalHours: number;
  totalFare: number; // calculated full amount
  paymentMethod: 'PhonePe' | 'Card' | 'COD';
  paymentStatus: 'Paid' | 'Pending';
  status: 'Confirmed' | 'Cancelled' | 'Completed';
  createdAt: string;
}

export interface TimeSlotOption {
  time: string;
  available: boolean;
}

export type UserRole = 'customer' | 'owner' | 'admin';

export interface Mechanic {
  id: string;
  name: string;
  specialty: string;
  phone: string;
  experienceYears: number;
  rating: number;
  baseFare: number; // e.g. 290 Rupees for major operations, or hourly repair base
  availabilityHours: string; // "6 AM - 8 PM"
  isApproved: boolean; // Managed by Admin
  photo: string;
  location?: string; // Bihar region details
}

export interface RepairBooking {
  id: string;
  userEmail: string;
  userName: string;
  mechanicId: string;
  mechanicName: string;
  vehicleNumber: string;
  vehicleType: 'Car' | 'Two-Wheeler' | string;
  description: string;
  bookingDate: string; // YYYY-MM-DD
  bookingTime: string; // e.g. "10:00 AM" or any selection
  originalFare: number;
  finalFare: number;
  isDiscountApplied: boolean;
  paymentMethod: 'PhonePe' | 'Card' | 'COD';
  paymentStatus: 'Paid' | 'Pending';
  status: 'Confirmed' | 'Cancelled' | 'Completed' | 'Scheduled' | 'Dispatched';
  createdAt: string;
  isEmergency?: boolean;
  location?: string;
}

export interface EmergencySubscription {
  id: string;
  userEmail: string;
  userName?: string;
  vehicleType?: 'Car' | 'Two-Wheeler' | string;
  vehicleNumber?: string;
  amountPaid: number; // ₹50
  prebookFare?: number;
  expiresAt: string; // ISO String for 24h expiration
  createdAt: string;
  status: 'Active' | 'Expired';
}

export interface UserAccount {
  id: string;
  email: string;
  name: string;
  password?: string;
  role: UserRole;
  isEmailVerified: boolean;
  verificationCode?: string; // 6-digit confirmation code
  createdAt: string;
  phone?: string;
  vehicleNo?: string;
  vehicleModel?: string;
  walletBalance?: number;
  completedCheckins?: number;
  nextDiscountPercent?: number; // e.g., 5% discount
  rewardsHistory?: any[];
}

export interface SupportTicket {
  id: string;
  userEmail: string;
  category: 'payment_failure' | 'property_visit' | 'charger_issue' | 'app_problem' | 'general' | 'refund';
  bookingId?: string;
  description: string;
  contactNo?: string;
  status: 'Open' | 'InProgress' | 'Resolved';
  resolution?: string;
  createdAt: string;
}

