export type Role = 'admin' | 'membre' | 'kiosk';
export type Patient = 'papa' | 'maman' | 'tous';
export type TaskCategory = 'soins' | 'logistique' | 'maison' | 'bienveillance';
export type DayOfWeek = 1 | 2 | 3 | 4 | 5 | 6 | 7; // 1 = Lundi, 7 = Dimanche

export interface User {
  id: number;
  nom: string;
  role: Role;
  code_pin?: string | null;
  actif: boolean;
}

export interface Task {
  id: number;
  nom: string;
  frequence: 'quotidien' | 'hebdomadaire' | 'mensuel';
  jours_semaine: number[];
  categorie: TaskCategory;
  afficher_alerte: boolean;
  afficher_carrousel: boolean;
}

export interface TaskInstance {
  id: number;
  tache_id: number;
  nom: string;
  categorie: TaskCategory;
  afficher_alerte: boolean;
  date: string; // YYYY-MM-DD
  fait: boolean;
  fait_par?: string | null;
  fait_a?: string | null;
}

export interface Medication {
  id: number;
  patient: 'papa' | 'maman';
  nom: string;
  dosage: string;
  moment: 'matin' | 'midi' | 'soir' | 'nuit' | 'si_besoin';
  heure_prevue: string; // HH:mm
}

export interface MedicationInstance {
  id: number;
  medicament_id: number;
  patient: 'papa' | 'maman';
  nom: string;
  dosage: string;
  moment: string;
  heure_prevue: string;
  date: string; // YYYY-MM-DD
  fait: boolean;
  fait_par?: string | null;
  fait_a?: string | null;
}

export interface Appointment {
  id: number;
  titre: string;
  patient: Patient;
  type: 'ponctuel' | 'recurrent';
  moment?: 'matin' | 'soir' | null;
  date_debut: string; // YYYY-MM-DD ou YYYY-MM-DD HH:mm
  lieu: string;
  notes?: string;
  accompagnant_id?: number | null;
}

export interface Presence {
  id: number;
  utilisateur_id: number;
  utilisateur_nom: string;
  date: string; // YYYY-MM-DD
  heure_debut: string; // HH:mm
  heure_fin: string; // HH:mm
}

export interface CarouselMessage {
  id: number;
  texte: string;
  date_debut?: string;
  date_fin?: string;
  actif: boolean;
}

export type AlertType = 'medicament' | 'tache' | 'rdv';

export interface AlertItem {
  id: string;
  type: AlertType;
  titre: string;
  heure: string;
  details?: string;
  sourceId: number;
  patient?: Patient;
}

export interface PendingUndoItem {
  id: string; // 'task-{id}' or 'med-{id}'
  type: 'tache' | 'medicament';
  sourceId: number;
  title: string;
  secondsRemaining: number;
  validatedBy: string;
}

export type ActiveScreen = 'dashboard' | 'presence' | 'taches' | 'medicaments' | 'rdv';
