export type TripStatus =
  | 'DRAFT'
  | 'PLANNING'
  | 'BOOKING'
  | 'UPCOMING'
  | 'ACTIVE'
  | 'COMPLETED'
  | 'ARCHIVED';

export interface Trip {
  id: string;
  name: string;
  description: string | null;
  ownerId: string;
  startDate: string | null;
  endDate: string | null;
  status: TripStatus;
  planningStage: string | null;
  currency: string;
  version: number;
  createdAt: Date;
  updatedAt: Date;
}

export interface CreateTripDto {
  name: string;
  description?: string;
  startDate?: string;
  endDate?: string;
  currency?: string;
}

export interface UpdateTripDto {
  name?: string;
  description?: string | null;
  startDate?: string | null;
  endDate?: string | null;
  status?: TripStatus;
  planningStage?: string | null;
  currency?: string;
  /** The caller's last-known version; required so stale concurrent writes are rejected. */
  version: number;
}

export type TripPlanningStyle = 'RELAXED' | 'BALANCED' | 'PACKED';
export type ResearchDepth = 'MINIMAL' | 'STANDARD' | 'THOROUGH';

export interface TripSettings {
  tripId: string;
  webResearchEnabled: boolean;
  periodicAgentReviewEnabled: boolean;
  notificationEmailEnabled: boolean;
  notificationPushEnabled: boolean;
  defaultResearchDepth: ResearchDepth | null;
  defaultPlanningStyle: TripPlanningStyle | null;
}

export interface UpdateTripSettingsDto {
  webResearchEnabled: boolean;
  periodicAgentReviewEnabled: boolean;
  notificationEmailEnabled: boolean;
  notificationPushEnabled: boolean;
  defaultResearchDepth: ResearchDepth | null;
  defaultPlanningStyle: TripPlanningStyle | null;
}

export type TripMemberRole = 'OWNER' | 'MEMBER';
export type TripMemberStatus = 'INVITED' | 'ACTIVE' | 'DECLINED';

export interface TripMember {
  id: string;
  tripId: string;
  userId: string;
  role: TripMemberRole;
  status: TripMemberStatus;
  joinedAt: Date | null;
  createdAt: Date;
  updatedAt: Date;
}

export interface TripInvitation {
  id: string;
  tripId: string;
  email: string;
  invitedByUserId: string;
  tokenHash: string;
  expiresAt: Date;
  acceptedAt: Date | null;
  createdAt: Date;
  updatedAt: Date;
}

export interface CreateTripInvitationFields {
  email: string;
  invitedByUserId: string;
  tokenHash: string;
  expiresAt: Date;
}

export const DEFAULT_TRIP_SETTINGS: Omit<TripSettings, 'tripId'> = {
  webResearchEnabled: false,
  periodicAgentReviewEnabled: false,
  notificationEmailEnabled: true,
  notificationPushEnabled: true,
  defaultResearchDepth: null,
  defaultPlanningStyle: null,
};
