export const getAuthToken = (): string | null => {
  try {
    if (typeof window === "undefined") return null;

    const directToken = localStorage.getItem("auth_token");
    if (directToken) return directToken;

    const storedUser = localStorage.getItem("user");
    const user = storedUser ? JSON.parse(storedUser) : null;
    return user?.state?.token || user?.token || user?.access_token || null;
  } catch {
    return null;
  }
};
