export interface LocationData {
  latitude: number;
  longitude: number;
  altitude: number | null;
  speed: number | null; // mph
  course: number | null;
  accuracy: number | null;
  battery: number | null;
  timestamp: string;
}

export interface DriverLocation {
  driverId: string;
  driverName: string;
  driverPhone: string | null;
  deviceIdentifier: string;
  isActive: boolean;
  lastActive: string | null;
  location: LocationData | null;
}

export interface GpsDevice {
  id: string;
  driverId: string;
  traccarDeviceId: number;
  deviceIdentifier: string;
  enrolledAt: string;
  consentGiven: boolean;
  consentGivenAt: string | null;
  lastActive: string | null;
  isActive: boolean;
  driver: {
    id: string;
    name: string;
    phone: string | null;
  };
}

export interface DriverStats {
  driverId: string;
  driverName: string;
  period: {
    from: string;
    to: string;
  };
  stats: {
    totalMiles: number;
    topSpeedMph: number;
    topSpeedTimestamp: string | null;
    averageSpeedMph: number;
    totalTrips: number;
    totalDrivingMinutes: number;
  };
  recentLocations: LocationData[];
}

export interface GpsStatus {
  traccarAvailable: boolean;
  traccarVersion: string | null;
  enrolledDrivers: number;
  activeDrivers: number;
  settings: {
    updateIntervalSeconds: number;
    shiftStartTime: string;
    shiftEndTime: string;
    retentionDays: number;
  };
}

export interface GpsSettings {
  id: string;
  updateIntervalSeconds: number;
  shiftStartHour: number;
  shiftStartMinute: number;
  shiftEndHour: number;
  shiftEndMinute: number;
  retentionDays: number;
  traccarAdminUser: string;
  traccarAdminPassword: string | null;
}

export interface EnrollmentResponse {
  success: boolean;
  deviceIdentifier: string;
  serverUrl: string;
  instructions: string;
  signalMessageSent?: boolean;
}

export interface MyGpsStatus {
  enrolled: boolean;
  driverId?: string;
  deviceIdentifier?: string;
  consentGiven?: boolean;
  consentGivenAt?: string;
  isActive?: boolean;
  lastActive?: string;
  message?: string;
}
