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

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

enum Role {
  ADMIN
  EDITOR
  USER
}

enum ApprovalStatus {
  PENDING
  APPROVED
  REJECTED
}

enum PublishStatus {
  DRAFT
  PUBLISHED
}

enum VideoKind {
  VIDEO
  SHORT
}

enum PageKey {
  HOME
  ABOUT
  CONTACT
}

model User {
  id           String   @id @default(cuid())
  name         String
  email        String   @unique
  bio          String?  @db.Text
  age          Int?
  sex          String?
  phone        String?
  address      String?
  passwordHash String
  role         Role     @default(ADMIN)
  isApproved   Boolean  @default(true)
  canManagePosts Boolean @default(false)
  canManageVideos Boolean @default(false)
  canManageGallery Boolean @default(false)
  canManagePages Boolean @default(false)
  canManageHome Boolean @default(false)
  canManageContact Boolean @default(false)
  posts        Post[]   @relation("PostAuthor")
  approvedPosts Post[]  @relation("PostApprover")
  videos       Video[]  @relation("VideoAuthor")
  approvedVideos Video[] @relation("VideoApprover")
  galleryImages GalleryImage[] @relation("GalleryAuthor")
  approvedGalleryImages GalleryImage[] @relation("GalleryApprover")
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
}

model Category {
  id          String   @id @default(cuid())
  name        String
  slug        String   @unique
  description String?
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  posts       Post[]
  videos      Video[]
}

model Post {
  id          String        @id @default(cuid())
  title       String
  slug        String        @unique
  excerpt     String
  content     String
  coverImage  String?
  seoTitle    String?
  seoDescription String? @db.Text
  seoKeywords String?
  status      PublishStatus @default(DRAFT)
  approvalStatus ApprovalStatus @default(APPROVED)
  rejectionReason String?   @db.Text
  featured    Boolean       @default(false)
  publishedAt DateTime?
  createdAt   DateTime      @default(now())
  updatedAt   DateTime      @updatedAt
  categoryId  String?
  category    Category?     @relation(fields: [categoryId], references: [id], onDelete: SetNull)
  authorId    String?
  author      User?         @relation("PostAuthor", fields: [authorId], references: [id], onDelete: SetNull)
  approvedById String?
  approvedBy  User?         @relation("PostApprover", fields: [approvedById], references: [id], onDelete: SetNull)
  tags        Tag[]         @relation("PostTags")
}

model Video {
  id          String        @id @default(cuid())
  title       String
  slug        String        @unique
  youtubeUrl  String
  youtubeId   String
  description String        @db.Text
  thumbnail   String?
  seoTitle    String?
  seoDescription String? @db.Text
  seoKeywords String?
  kind        VideoKind     @default(VIDEO)
  status      PublishStatus @default(DRAFT)
  approvalStatus ApprovalStatus @default(APPROVED)
  rejectionReason String?   @db.Text
  featured    Boolean       @default(false)
  publishedAt DateTime?
  createdAt   DateTime      @default(now())
  updatedAt   DateTime      @updatedAt
  categoryId  String?
  category    Category?     @relation(fields: [categoryId], references: [id], onDelete: SetNull)
  authorId    String?
  author      User?         @relation("VideoAuthor", fields: [authorId], references: [id], onDelete: SetNull)
  approvedById String?
  approvedBy  User?         @relation("VideoApprover", fields: [approvedById], references: [id], onDelete: SetNull)
  tags        Tag[]         @relation("VideoTags")
}

model HomeSlide {
  id        String   @id @default(cuid())
  title     String
  subtitle  String
  imageUrl  String
  ctaLabel  String?
  ctaHref   String?
  sortOrder Int      @default(0)
  active    Boolean  @default(true)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model GalleryImage {
  id          String   @id @default(cuid())
  title       String
  description String?
  imageUrl    String
  seoTitle    String?
  seoDescription String? @db.Text
  seoKeywords String?
  sortOrder   Int      @default(0)
  active      Boolean  @default(true)
  approvalStatus ApprovalStatus @default(APPROVED)
  rejectionReason String? @db.Text
  authorId    String?
  author      User?    @relation("GalleryAuthor", fields: [authorId], references: [id], onDelete: SetNull)
  approvedById String?
  approvedBy  User?    @relation("GalleryApprover", fields: [approvedById], references: [id], onDelete: SetNull)
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

model Review {
  id        String   @id @default(cuid())
  name      String
  location  String?
  rating    Int      @default(5)
  message   String
  active    Boolean  @default(true)
  approvalStatus ApprovalStatus @default(APPROVED)
  rejectionReason String? @db.Text
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model SiteSetting {
  id                 String   @id @default(cuid())
  key                String   @unique
  logoUrl            String?
  faviconUrl         String?
  aboutBrandImageUrl String?
  aboutCreatorImageUrl String?
  neuralColorA       String?  @default("#00ffff")
  neuralColorB       String?  @default("#0088ff")
  neuralColorC       String?  @default("#ffd700")
  updatedAt          DateTime @updatedAt
}

model ContactSetting {
  id        String   @id @default(cuid())
  key       String   @unique
  fullName  String?
  email     String?
  phone     String?
  address   String?
  creatorExperience String?
  creatorSkills String? @db.Text
  mapUrl    String?
  portfolio String?
  whatsapp  String?
  github    String?
  facebook  String?
  instagram String?
  youtube   String?
  tiktok    String?
  xUrl      String?
  linkedin  String?
  updatedAt DateTime @updatedAt
}

model Tag {
  id     String  @id @default(cuid())
  name   String
  slug   String  @unique
  posts  Post[]  @relation("PostTags")
  videos Video[] @relation("VideoTags")
}

model PageContent {
  id          String   @id @default(cuid())
  key         PageKey  @unique
  title       String
  subtitle    String
  body        String
  ctaLabel    String?
  ctaHref     String?
  heroImage   String?
  seoTitle    String?
  seoDescription String? @db.Text
  seoKeywords String?
  updatedAt   DateTime @updatedAt
}

model Subscriber {
  id        String   @id @default(cuid())
  email     String   @unique
  createdAt DateTime @default(now())
}

model ContactMessage {
  id        String   @id @default(cuid())
  name      String
  phone     String?
  email     String
  message   String
  isRead    Boolean  @default(false)
  readAt    DateTime?
  createdAt DateTime @default(now())
}
