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

generator client {
  provider = "prisma-client"
  output   = "./generated/prisma"
}

datasource db {
  provider = "sqlite"
}

enum Role {
  USER
  ADMIN
}

enum EventType {
  SUMMIT
  LAUNCH
  FESTIVAL
  COMPETITION
}

enum EventStatus {
  UPCOMING
  LIVE
  PAST
}

model User {
  id            String    @id @default(cuid())
  email         String    @unique
  password      String
  username      String    @unique
  role          Role      @default(USER)
  score         Int       @default(0)
  level         Int       @default(1)
  hp            Int       @default(1000)
  maxHp         Int       @default(1000)
  xp            Int       @default(0)
  maxXp         Int       @default(5000)
  avatar        String?
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  preferences   UserPreferences?
  
  @@index([score])
  @@index([email])
}

model UserPreferences {
  id              String   @id @default(cuid())
  userId          String   @unique
  user            User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  
  // Background images for each page
  homeBackground  String?
  eventsBackground String?
  leaderboardBackground String?
  
  // Other UI preferences can be added here
  theme           String?  @default("default")
  
  createdAt       DateTime @default(now())
  updatedAt       DateTime @updatedAt
}

model Event {
  id          String      @id @default(cuid())
  date        String
  name        String
  description String
  type        EventType
  status      EventStatus
  createdAt   DateTime    @default(now())
  updatedAt   DateTime    @updatedAt
  
  @@index([status])
  @@index([date])
}

model SitePreferences {
  id                    String   @id @default("global")
  homeBackground        String?
  eventsBackground      String?
  leaderboardBackground String?
  createdAt             DateTime @default(now())
  updatedAt             DateTime @updatedAt
}
