export type AdminStats = {
  totalCafes: number;
  activeCafes: number;
  suspendedCafes: number;
  openTickets: number;
  plansConfigured: number;
};

export type PlanLimitsData = {
  maxOrdersPerDay: number;
  maxTerminals: number;
  maxCustomers: number;
  maxSmsPerMonth: number;
  maxBranches: number;
  maxReportHistoryDays: number;
};

export type AdminPlan = {
  tier: string;
  displayNameFa: string;
  displayNameEn?: string | null;
  monthlyPriceToman: number;
  isBillableOnline: boolean;
  isActive: boolean;
  sortOrder: number;
  limits: PlanLimitsData;
  featureKeys: string[];
};

export type PlatformSetting = {
  id: string;
  key: string;
  value: string;
  category: string;
  descriptionFa?: string | null;
  updatedAt: string;
};

export type PlatformFeature = {
  id: string;
  key: string;
  displayNameFa: string;
  displayNameEn?: string | null;
  moduleGroup: string;
  isEnabledGlobally: boolean;
  updatedAt: string;
};

export type AdminCafe = {
  id: string;
  name: string;
  slug: string;
  city: string;
  planTier: string;
  planExpiresAt?: string | null;
  isSuspended: boolean;
  isVerified: boolean;
  branchCount: number;
  employeeCount: number;
  createdAt: string;
};

export type SupportTicket = {
  id: string;
  cafeId: string;
  cafeName: string;
  subject: string;
  status: string;
  priority: string;
  createdByEmployeeId: string;
  createdByName?: string | null;
  assignedAdminId?: string | null;
  createdAt: string;
  updatedAt: string;
  messageCount: number;
};

export type SupportTicketMessage = {
  id: string;
  senderKind: string;
  senderId: string;
  senderName?: string | null;
  body: string;
  createdAt: string;
};

export type SupportTicketDetail = {
  ticket: SupportTicket;
  messages: SupportTicketMessage[];
};

export type GatewayCredentials = {
  username?: string | null;
  password?: string | null;
  branchCode?: string | null;
  terminalCode?: string | null;
  clientId?: string | null;
  clientSecret?: string | null;
  baseUrl?: string | null;
  hasStoredPassword: boolean;
  hasStoredClientSecret: boolean;
};

export type PaymentGatewayConfig = {
  id: string;
  displayNameFa: string;
  isEnabled: boolean;
  isActive: boolean;
  merchantId?: string | null;
  apiKey?: string | null;
  sandbox: boolean;
  hasStoredSecret: boolean;
  credentials?: GatewayCredentials | null;
};

export type KavenegarConfig = {
  isEnabled: boolean;
  apiKey?: string | null;
  otpTemplate: string;
  hasStoredApiKey: boolean;
};

export type OpenAiIntegrationConfig = {
  isEnabled: boolean;
  apiKey?: string | null;
  model: string;
  coffeeAdvisorEnabled: boolean;
  hasStoredApiKey: boolean;
};

export type MeshyIntegrationConfig = {
  isEnabled: boolean;
  apiKey?: string | null;
  menu3dEnabled: boolean;
  hasStoredApiKey: boolean;
};

export type AiIntegrationsConfig = {
  openAi: OpenAiIntegrationConfig;
  meshy: MeshyIntegrationConfig;
};

export type PlatformIntegrations = {
  activePaymentGateway: string;
  paymentGateways: PaymentGatewayConfig[];
  kavenegar: KavenegarConfig;
  ai: AiIntegrationsConfig;
};

export type AdminNotificationRow = {
  id: string;
  cafeId: string;
  cafeName: string;
  type: string;
  title: string;
  body?: string | null;
  isRead: boolean;
  createdAt: string;
};

export type BroadcastResult = {
  cafeCount: number;
  notificationCount: number;
};

// ── Website CMS ──────────────────────────────────────────────────────────────

export type AdminBlogPost = {
  id: string;
  slug: string;
  titleFa: string;
  titleEn: string;
  excerptFa: string;
  excerptEn: string;
  author: string;
  categoryFa: string;
  categoryEn: string;
  isPublished: boolean;
  publishedAt?: string | null;
  viewCount: number;
  commentCount: number;
  createdAt: string;
  updatedAt: string;
};

export type AdminBlogPostDetail = AdminBlogPost & {
  contentFa: string;
  contentEn: string;
  coverImage?: string | null;
  tagsJson: string;
};

export type AdminComment = {
  id: string;
  postSlug: string;
  authorName: string;
  authorEmail?: string | null;
  content: string;
  isApproved: boolean;
  ipAddress?: string | null;
  createdAt: string;
};

export type AdminDemoRequest = {
  id: string;
  contactName: string;
  businessName: string;
  phone: string;
  email?: string | null;
  branchCount: string;
  notes?: string | null;
  source: string;
  status: "New" | "Contacted" | "DemoScheduled" | "Converted" | "Rejected";
  adminNotes?: string | null;
  contactedAt?: string | null;
  createdAt: string;
};
