
export interface ServiceAddon {
  id: string;
  serviceId?: number;
  name: string;
  recurringAmount: number;
  billingCycle: string;
  status: string;
  nextDueDate: string;
  regDate: string;
  customFields?: Array<{ id?: string; name: string; value: string }>;
}

export interface Service {
  id: number;
  productName: string;
  domain: string;
  productId: number;
  groupId: number;
  status: 'Active' | 'Pending' | 'Suspended' | 'Terminated';
  billingCycle: string;
  recurringAmount: number;
  nextDueDate: string;
  regDate: string;
  type: 'hosting' | 'vps' | 'domain' | 'reseller' | 'dedicated' | 'colocation';
  username?: string;
  password?: string;
  serverIp?: string;
  serverId?: number;
  diskLimit?: string;
  diskUsage?: string;
  bwLimit?: string;
  bwUsage?: string;
  rackSpace?: string;
  datacenter?: string;
  rackUnit?: string;
  allocatedPower?: string;
  connectivity?: string;
  switchDetails?: string;
  switchPort?: string;
  router?: string;
  rackNumber?: string;
  serviceType?: string;
  setupStatus?: string;
  vpsId?: string;
  addons?: ServiceAddon[];
  customFields?: Array<{ id?: string; name: string; value: string }>;
}

export interface Domain {
  id: number;
  domain: string;
  status: 'Active' | 'Expired' | 'Pending' | 'Transferred Away';
  expiryDate: string;
  regDate: string;
  recurringAmount: number;
  registrarLock: boolean;
  nameservers: string[];
  authCode?: string;
}

export interface Invoice {
  id: string;
  date: string;
  dueDate: string;
  total: number;
  status: 'Paid' | 'Unpaid' | 'Cancelled' | 'Refunded';
}

export interface InvoiceItem {
  id: number;
  description: string;
  amount: number;
  taxed: boolean;
  relid?: number;
  type?: string;
}

export interface InvoiceTransaction {
  date: string;
  gateway: string;
  transId: string;
  amount: number;
}

export interface InvoiceDetail extends Invoice {
  subtotal: number;
  tax: number;
  credit: number;
  balance: number;
  paymentMethod: string;
  items: InvoiceItem[];
  transactions?: InvoiceTransaction[];
}

export interface Ticket {
  id: number;
  subject: string;
  date: string;
  department: string;
  status: 'Open' | 'Answered' | 'Customer-Reply' | 'Closed';
  lastUpdated: string;
  priority: 'Low' | 'Medium' | 'High';
}

export interface TicketReply {
  id: number;
  userId: number;
  name: string;
  email: string;
  date: string;
  message: string;
  attachment?: string;
  admin?: string;
}

export interface TicketDetail extends Ticket {
  replies: TicketReply[];
  serviceId?: number;
  message?: string;
}

export interface Department {
  id: number;
  name: string;
}

export interface ClientStats {
  activeServices: number;
  unpaidInvoices: number;
  openTickets: number;
  totalBalance: number;
  currencyPrefix?: string;
  currencySuffix?: string;
  currencyCode?: string;
  creditBalance: number;
  clientName?: string;
  clientEmail?: string;
  email?: string;
  address1?: string;
  city?: string;
  state?: string;
  postcode?: string;
  country?: string;
  userid?: number;
}

export interface ClientDetails {
  id: number;
  firstname: string;
  lastname: string;
  companyname: string;
  email: string;
  address1: string;
  address2: string;
  city: string;
  state: string;
  postcode: string;
  country: string;
  phonenumber: string;
  paymentmethod: string;
  billingcid: number;
  currency: number;
  defaultgateway: string;
  language: string;
  notes: string;
  twofaenabled: boolean;
  currency_code: string;
  customfields?: Array<{ id: string; name: string; value: string }>;
}

export interface User {
  id: number;
  name: string;
  email: string;
  lastLogin: string;
  isOwner: boolean;
  permissions?: string[];
}

export interface EmailMessage {
  id: number;
  date: string;
  subject: string;
  message?: string;
}

export enum DashboardView {
  OVERVIEW = 'overview',
  SERVICES = 'services',
  HOSTING = 'hosting',
  VIRTUAL_SERVERS = 'virtual_servers',
  DEDICATED_SERVERS = 'dedicated_servers',
  COLOCATION = 'colocation',
  SERVICE_DETAIL = 'service_detail',
  DOMAINS = 'domains',
  DOMAIN_DETAIL = 'domain_detail',
  BILLING = 'billing',
  SUPPORT = 'support',
  SETTINGS = 'settings',
  SEARCH = 'search',
  CART = 'cart',
  ORDER = 'order',
  MY_DETAILS = 'my_details',
  USER_MANAGEMENT = 'user_management',
  EMAIL_HISTORY = 'email_history',
  ADMIN = 'admin'
}

export interface WHMCSConfig {
  url: string;
  apiIdentifier: string;
  apiSecret: string;
}

export interface CartItem {
  pid: number;
  name: string;
  price: number;
  billingCycle: string;
  domain?: string;
  domainType?: 'register' | 'transfer' | 'existing';
  regPeriod?: number; // Years
  eppCode?: string;
  configOptions?: Record<number, number>; // OptionID -> ValueID
  customFields?: Record<number, string>; // FieldID -> Value
  addons?: number[];
}

export interface StoreGroup {
  id: number;
  name: string;
}

export interface StoreProduct {
  id: number;
  groupId: number;
  name: string;
  description: string;
  price: number;
  billingCycle: string;
  stockControl?: boolean;
  stockLevel?: number;
  showDomainOptions?: boolean;
  hasConfigOptions?: boolean;
  pricing?: {
    monthly?: string;
    quarterly?: string;
    semiannually?: string;
    annually?: string;
    biennially?: string;
    triennially?: string;
  };
}

export interface PaymentMethod {
  module: string;
  displayName: string;
}

export interface UpgradeOption {
  id: number;
  name: string;
  description: string;
  price: string;
  billingCycles: string[];
}

export interface UpgradeCalculation {
  total: number;
  subtotal: number;
  tax: number;
  credit: number;
  balance: number;
  newRecurringAmount: number;
  upgradeinprogress?: boolean;
}

export interface LoginSlide {
  id: number;
  image: string;
  title: string;
  subtitle: string;
}

export interface BrandingConfig {
  appName: string;
  appLogo: string;
  footerText: string;
  loginTitle: string;
  loginSubtitle: string;
  companyName?: string;
  companyAddress?: string;
  loginSlides?: LoginSlide[];
}
