// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

// Modèle pour les parents
model Parent {
  id            String    @id @default(uuid())
  email         String    @unique
  password      String
  firstName     String
  lastName      String
  phoneNumber   String?
  address       String?
  status        AccountStatus @default(PENDING)
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  children      Child[]
  contracts     Contract[]
}

// Modèle pour les enfants
model Child {
  id            String    @id @default(uuid())
  firstName     String
  dateOfBirth   DateTime
  photoUrl      String?
  photoConsent  Boolean   @default(false)
  isMultiple    Boolean   @default(false)
  isUnborn      Boolean   @default(false)
  parentId      String
  parent        Parent    @relation(fields: [parentId], references: [id])
  contracts     Contract[]
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
}

// Modèle pour les contrats
model Contract {
  id            String    @id @default(uuid())
  parentId      String
  childId       String
  startDate     DateTime
  endDate       DateTime?
  status        ContractStatus @default(ACTIVE)
  parent        Parent    @relation(fields: [parentId], references: [id])
  child         Child     @relation(fields: [childId], references: [id])
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
}

// Modèle pour les thèmes
model Theme {
  id            String    @id @default(uuid())
  name          String    @unique
  primaryColor  String
  secondaryColor String
  backgroundColor String
  textColor     String
  isActive      Boolean   @default(false)
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  appSettings   AppSettings[]
}

// Modèle pour les paramètres de l'application
model AppSettings {
  id            String    @id @default(uuid())
  currentThemeId String
  currentTheme  Theme     @relation(fields: [currentThemeId], references: [id])
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt

  @@index([currentThemeId])
}

// Modèle pour les administrateurs
model Admin {
  id            String    @id @default(uuid())
  email         String    @unique
  password      String
  firstName     String
  lastName      String
  passwordChanged Boolean @default(false)
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
}

// Enums
enum AccountStatus {
  PENDING
  VALIDATED
  REJECTED
  SUSPENDED
}

enum ContractStatus {
  ACTIVE
  ENDED
  CANCELLED
} 