export type Category =
  | 'ELECTRONICS'
  | 'FURNITURE'
  | 'CLOTHING'
  | 'HOME_GARDEN'
  | 'SPORTS'
  | 'BOOKS'
  | 'GAMES'
  | 'VEHICLES'
  | 'OTHER';

export type ListingCondition = 'NEW' | 'LIKE_NEW' | 'GENTLY_USED' | 'USED' | 'FAIR';

export type ListingStatus = 'DRAFT' | 'ACTIVE' | 'PENDING_REVIEW' | 'SOLD' | 'DELETED';

export type OfferStatus = 'PENDING' | 'ACCEPTED' | 'DECLINED' | 'COUNTERED' | 'CANCELLED' | 'EXPIRED';

export type NotificationType = 'NEW_OFFER' | 'OFFER_ACCEPTED' | 'OFFER_DECLINED' | 'ITEM_SOLD' | 'NEW_MESSAGE' | 'ITEM_FAVORITED' | 'LISTING_APPROVED' | 'LISTING_REJECTED' | 'MODERATION_WARNING' | 'ACCOUNT_BANNED' | 'ACCOUNT_UNBANNED' | 'REPORT_RESOLVED' | 'BOOKING_REQUEST' | 'BOOKING_CONFIRMED' | 'BOOKING_REJECTED' | 'BOOKING_CANCELLED' | 'BOOKING_STARTED' | 'BOOKING_COMPLETED' | 'RENTAL_REVIEW' | 'PAYOUT_SENT' | 'PAYOUT_FAILED';

export interface User {
  id: string;
  email: string;
  fullName: string;
  nickname?: string;
  avatar?: string;
  phone?: string;
  location?: string;
  bio?: string;
  rating?: number;
  ratingCount?: number;
  createdAt: string;
  role?: string;
  isLandlord?: boolean;
  landlordVerified?: boolean;
  showEmail: boolean;
  showPhone: boolean;
  showLocation: boolean;
}

export interface ListingImage {
  id: string;
  url: string;
  order: number;
}

export interface Listing {
  id: string;
  title: string;
  description: string;
  price: number;
  obo: boolean;
  category: Category;
  condition: ListingCondition;
  status: ListingStatus;
  location: string;
  viewCount: number;
  images: ListingImage[];
  seller: User;
  sellerId: string;
  isFavorited?: boolean;
  createdAt: string;
  updatedAt: string;
}

export interface Offer {
  id: string;
  amount: number;
  message?: string;
  status: OfferStatus;
  counterAmount?: number;
  expiresAt?: string;
  buyer: User;
  buyerId: string;
  seller: User;
  sellerId: string;
  listing: Listing;
  listingId: string;
  createdAt: string;
  updatedAt: string;
}

export interface Message {
  id: string;
  content: string;
  senderId: string;
  conversationId: string;
  isRead: boolean;
  offerAmount?: number;
  createdAt: string;
}

export interface Conversation {
  id: string;
  user1: User;
  user2: User;
  listing?: Listing;
  lastMessage?: Message;
  unreadCount: number;
  updatedAt: string;
}

export interface Notification {
  id: string;
  type: NotificationType;
  title: string;
  body: string;
  data?: Record<string, unknown>;
  isRead: boolean;
  createdAt: string;
}

export interface AuthResponse {
  user: User;
  accessToken: string;
}

export interface PaginatedResponse<T> {
  data: T[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}

export type UserRole = 'USER' | 'MODERATOR' | 'ADMIN' | 'SUPER_ADMIN';

export type ReportReason = 'SPAM' | 'INAPPROPRIATE' | 'SCAM' | 'COUNTERFEIT' | 'PROHIBITED_ITEM' | 'HARASSMENT' | 'OTHER';
export type ReportStatus = 'OPEN' | 'REVIEWING' | 'RESOLVED' | 'DISMISSED';

export interface Report {
  id: string;
  reporterId: string;
  targetType: 'LISTING' | 'USER';
  targetId: string;
  reason: ReportReason;
  description?: string;
  status: ReportStatus;
  resolvedBy?: string;
  resolution?: string;
  reporter?: User;
  createdAt: string;
  updatedAt: string;
}

export interface PlatformConfig {
  id: string;
  listingFee: number;
  commissionPercent: number;
  autoApprove: boolean;
  maxImagesPerListing: number;
  maxListingsFreeTier: number;
  proPrice: number;
  businessPrice: number;
  promotionDayPrice: number;
  blockedKeywords: string[];
  rentalCommissionPercent: number;
  rentalAutoApprove: boolean;
  maxRentalImagesPerListing: number;
  bookingExpiryHours: number;
  rentalPromotionDayPrice: number;
}

export type { RentalListing, Booking as RentalBooking, Payout, RentalReview, RentalStats, AvailabilityBlock, RentalCategory, BookingStatus as RentalBookingStatus, PayoutStatus, CancellationPolicy, RentalPeriodType, RentalListingStatus } from './rental';

export interface ModerationLog {
  id: string;
  moderatorId: string;
  targetUserId?: string;
  targetListingId?: string;
  action: string;
  reason?: string;
  details?: Record<string, unknown>;
  moderator?: User;
  createdAt: string;
}

export interface AdminStats {
  totalUsers: number;
  totalListings: number;
  activeListings: number;
  pendingListings: number;
  totalOffers: number;
  totalRevenue: number;
  activeToday: number;
}
