/**
 * Subscription API Types - Mirror backend schemas
 */

export interface SubscriptionLimits {
  max_users: number;
  max_sales_records: number;
  max_inventory_items: number;
  max_api_requests_per_hour: number;
  features_enabled: string[];
  current_usage: {
    users: number;
    sales_records: number;
    inventory_items: number;
    api_requests_this_hour: number;
  };
}

export interface FeatureCheckRequest {
  feature_name: string;
  tenant_id: string;
}

export interface FeatureCheckResponse {
  enabled: boolean;
  limit?: number;
  current_usage?: number;
  message?: string;
}

export interface UsageCheckRequest {
  resource_type: 'users' | 'sales_records' | 'inventory_items' | 'api_requests';
  tenant_id: string;
  requested_amount?: number;
}

export interface UsageCheckResponse {
  allowed: boolean;
  limit: number;
  current_usage: number;
  remaining: number;
  message?: string;
}

export interface UsageSummary {
  plan: string;
  status: 'active' | 'inactive' | 'past_due' | 'cancelled';
  monthly_price: number;
  next_billing_date: string;
  usage: {
    users: {
      current: number;
      limit: number;
      unlimited: boolean;
      usage_percentage: number;
    };
    locations: {
      current: number;
      limit: number;
      unlimited: boolean;
      usage_percentage: number;
    };
    products: {
      current: number;
      limit: number;
      unlimited: boolean;
      usage_percentage: number;
    };
  };
}

export interface Plan {
  name: string;
  description: string;
  monthly_price: number;
  max_users: number;
  max_locations: number;
  max_products: number;
  popular?: boolean;
  contact_sales?: boolean;
}

export interface AvailablePlans {
  plans: {
    [key: string]: Plan;
  };
}

export interface PlanUpgradeValidation {
  can_upgrade: boolean;
  reason?: string;
}

export interface PlanUpgradeResult {
  success: boolean;
  message: string;
}