export interface PlanLimits {
  docs_per_month: number;
  max_pages_per_doc: number;
}

export interface AdminUser {
  id: string;
  email: string;
  name: string;
  plan: "free" | "starter" | "pro" | "business" | "enterprise";
  subscription_status: "active" | "suspended" | "pending" | "cancelled";
  docs_translated_this_month: number;
  pages_translated_this_month: number;
  extra_credits: number;
  created_at: string;
  plan_limits: PlanLimits;
  api_keys_count?: number;
  api_key_ids?: string[];
  /** Présent si le backend expose la source du compte */
  storage?: "database" | "json_file";
}

export interface AdminUsersResponse {
  total: number;
  users: AdminUser[];
}

export interface UpdateTierRequest {
  plan: "free" | "starter" | "pro" | "business" | "enterprise";
}

export interface UpdateTierResponse {
  data: {
    id: string;
    email: string;
    name: string;
    plan: string;
    tier: "free" | "pro";
  };
  meta: Record<string, unknown>;
}

export interface RevokeApiKeyResponse {
  data: {
    id: string;
    revoked: boolean;
    revoked_at: string;
    owner_user_id: string;
    reason?: string;
  };
  meta: Record<string, unknown>;
}

export type PlanType = "free" | "starter" | "pro" | "business" | "enterprise";

export const PLAN_LABELS: Record<PlanType, string> = {
  free: "Free",
  starter: "Starter",
  pro: "Pro",
  business: "Business",
  enterprise: "Enterprise",
};

export const PLAN_TIERS: Record<PlanType, "free" | "pro"> = {
  free: "free",
  starter: "free",
  pro: "pro",
  business: "pro",
  enterprise: "pro",
};
